Skip to content

Commit f9bb3aa

Browse files
committed
---
yaml --- r: 35679 b: refs/heads/master c: 82641d4 h: refs/heads/master i: 35677: 685bf3e 35675: 876d62a 35671: 24c4cd0 35663: bd41d3f 35647: 7d0c50b v: v3
1 parent 73a2862 commit f9bb3aa

File tree

9 files changed

+616
-370
lines changed

9 files changed

+616
-370
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2fd8ebd03a9195bf7e2e3a811ec1dc0f1f2654db
2+
refs/heads/master: 82641d4c39dd547c44c2d2ef4c0c98c5bfbd8b55
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/doc/rust.md

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -876,13 +876,6 @@ fn add(x: int, y: int) -> int {
876876
}
877877
~~~~
878878

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-
886879

887880
#### Generic functions
888881

@@ -1229,44 +1222,17 @@ impl float: Num {
12291222
let x: float = Num::from_int(42);
12301223
~~~~
12311224

1232-
Traits may inherit from other traits. For example, in
1225+
Traits can have _constraints_ for example, in
12331226

12341227
~~~~
12351228
trait Shape { fn area() -> float; }
12361229
trait Circle : Shape { fn radius() -> float; }
12371230
~~~~
12381231

12391232
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 { }`.
12411233
In an implementation of `Circle` for a given type `T`, methods can refer to `Shape` methods,
12421234
since the typechecker checks that any type with an implementation of `Circle` also has an implementation of `Shape`.
12431235

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-
12701236
### Implementations
12711237

12721238
An _implementation_ is an item that implements a [trait](#traits) for a specific type.
@@ -2879,16 +2845,6 @@ The kinds are:
28792845
sendable kind are copyable, as are managed boxes, managed closures,
28802846
trait types, and structural types built out of these.
28812847
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-
28922848
_Default_
28932849
: Types with destructors, closure environments,
28942850
and various other _non-first-class_ types,

0 commit comments

Comments
 (0)