@@ -876,13 +876,6 @@ fn add(x: int, y: int) -> int {
876
876
}
877
877
~~~~
878
878
879
- As with ` let ` bindings, function arguments are irrefutable patterns,
880
- so any pattern that is valid in a let binding is also valid as an argument.
881
-
882
- ~~~
883
- fn first((value, _): (int, int)) -> int { value }
884
- ~~~
885
-
886
879
887
880
#### Generic functions
888
881
@@ -1229,44 +1222,17 @@ impl float: Num {
1229
1222
let x: float = Num::from_int(42);
1230
1223
~~~~
1231
1224
1232
- Traits may inherit from other traits. For example, in
1225
+ Traits can have _ constraints _ for example, in
1233
1226
1234
1227
~~~~
1235
1228
trait Shape { fn area() -> float; }
1236
1229
trait Circle : Shape { fn radius() -> float; }
1237
1230
~~~~
1238
1231
1239
1232
the syntax ` Circle : Shape ` means that types that implement ` Circle ` must also have an implementation for ` Shape ` .
1240
- Multiple supertraits are separated by spaces, ` trait Circle : Shape Eq { } ` .
1241
1233
In an implementation of ` Circle ` for a given type ` T ` , methods can refer to ` Shape ` methods,
1242
1234
since the typechecker checks that any type with an implementation of ` Circle ` also has an implementation of ` Shape ` .
1243
1235
1244
- In type-parameterized functions,
1245
- methods of the supertrait may be called on values of subtrait-bound type parameters.
1246
- Refering to the previous example of ` trait Circle : Shape ` :
1247
-
1248
- ~~~
1249
- # trait Shape { fn area() -> float; }
1250
- # trait Circle : Shape { fn radius() -> float; }
1251
- fn radius_times_area<T: Circle>(c: T) -> float {
1252
- // `c` is both a Circle and a Shape
1253
- c.radius() * c.area()
1254
- }
1255
- ~~~
1256
-
1257
- Likewise, supertrait methods may also be called on trait objects.
1258
-
1259
- ~~~ {.xfail-test}
1260
- # trait Shape { fn area() -> float; }
1261
- # trait Circle : Shape { fn radius() -> float; }
1262
- # impl int: Shape { fn area() -> float { 0.0 } }
1263
- # impl int: Circle { fn radius() -> float { 0.0 } }
1264
- # let mycircle = 0;
1265
-
1266
- let mycircle: Circle = @mycircle as @Circle;
1267
- let nonsense = mycircle.radius() * mycircle.area();
1268
- ~~~
1269
-
1270
1236
### Implementations
1271
1237
1272
1238
An _ implementation_ is an item that implements a [ trait] ( #traits ) for a specific type.
@@ -2879,16 +2845,6 @@ The kinds are:
2879
2845
sendable kind are copyable, as are managed boxes, managed closures,
2880
2846
trait types, and structural types built out of these.
2881
2847
Types with destructors (types that implement ` Drop ` ) can not implement ` Copy ` .
2882
- ` Drop `
2883
- : This is not strictly a kind, but its presence interacts with kinds: the ` Drop `
2884
- trait provides a single method ` finalize ` that takes no parameters, and is run
2885
- when values of the type are dropped. Such a method is called a "destructor",
2886
- and are always executed in "top-down" order: a value is completely destroyed
2887
- before any of the values it owns run their destructors. Only ` Owned ` types
2888
- that do not implement ` Copy ` can implement ` Drop ` .
2889
-
2890
- > ** Note:** The ` finalize ` method may be renamed in future versions of Rust.
2891
-
2892
2848
_ Default_
2893
2849
: Types with destructors, closure environments,
2894
2850
and various other _ non-first-class_ types,
0 commit comments