Skip to content

Commit 73fc9e6

Browse files
committed
---
yaml --- r: 46966 b: refs/heads/try c: afe73cc h: refs/heads/master v: v3
1 parent 37a6b2c commit 73fc9e6

File tree

604 files changed

+1399
-1333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

604 files changed

+1399
-1333
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: 5d62a4a52e90cf5d5c1c0229db64e5683dffe732
5+
refs/heads/try: afe73ccad916624c9ed9df18f49ab6f3ad9c9cb4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/doc/rust.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ to pointers to the trait name, used as a type.
12091209

12101210
~~~~
12111211
# trait Shape { }
1212-
# impl Shape for int { }
1212+
# impl int: Shape { }
12131213
# let mycircle = 0;
12141214
12151215
let myshape: Shape = @mycircle as @Shape;
@@ -1233,7 +1233,7 @@ For example:
12331233
trait Num {
12341234
static pure fn from_int(n: int) -> Self;
12351235
}
1236-
impl Num for float {
1236+
impl float: Num {
12371237
static pure fn from_int(n: int) -> float { n as float }
12381238
}
12391239
let x: float = Num::from_int(42);
@@ -1269,8 +1269,8 @@ Likewise, supertrait methods may also be called on trait objects.
12691269
~~~ {.xfail-test}
12701270
# trait Shape { fn area() -> float; }
12711271
# trait Circle : Shape { fn radius() -> float; }
1272-
# impl Shape for int { fn area() -> float { 0.0 } }
1273-
# impl Circle for int { fn radius() -> float { 0.0 } }
1272+
# impl int: Shape { fn area() -> float { 0.0 } }
1273+
# impl int: Circle { fn radius() -> float { 0.0 } }
12741274
# let mycircle = 0;
12751275
12761276
let mycircle: Circle = @mycircle as @Circle;
@@ -1292,7 +1292,7 @@ Implementations are defined with the keyword `impl`.
12921292
12931293
type Circle = {radius: float, center: Point};
12941294
1295-
impl Shape for Circle {
1295+
impl Circle: Shape {
12961296
fn draw(s: Surface) { do_draw_circle(s, self); }
12971297
fn bounding_box() -> BoundingBox {
12981298
let r = self.radius;
@@ -1303,9 +1303,9 @@ impl Shape for Circle {
13031303
~~~~
13041304

13051305
It is possible to define an implementation without referring to a trait.
1306-
The methods in such an implementation can only be used
1307-
as direct calls on the values of the type that the implementation targets.
1308-
In such an implementation, the trait type and `for` after `impl` are omitted.
1306+
The methods in such an implementation can only be used statically
1307+
(as direct calls on the values of the type that the implementation targets).
1308+
In such an implementation, the type after the colon is omitted.
13091309
Such implementations are limited to nominal types (enums, structs),
13101310
and the implementation must appear in the same module or a sub-module as the `self` type.
13111311

@@ -1320,10 +1320,10 @@ Implementation parameters are written after after the `impl` keyword.
13201320
~~~~
13211321
# trait Seq<T> { }
13221322
1323-
impl<T> Seq<T> for ~[T] {
1323+
impl<T> ~[T]: Seq<T> {
13241324
...
13251325
}
1326-
impl Seq<bool> for u32 {
1326+
impl u32: Seq<bool> {
13271327
/* Treat the integer as a sequence of bits */
13281328
}
13291329
~~~~
@@ -2801,7 +2801,7 @@ trait Printable {
28012801
fn to_str() -> ~str;
28022802
}
28032803
2804-
impl Printable for int {
2804+
impl int: Printable {
28052805
fn to_str() -> ~str { int::to_str(self) }
28062806
}
28072807
@@ -2844,7 +2844,7 @@ trait Printable {
28442844
fn make_string() -> ~str;
28452845
}
28462846
2847-
impl Printable for ~str {
2847+
impl ~str: Printable {
28482848
fn make_string() -> ~str { copy self }
28492849
}
28502850
~~~~~~~~

branches/try/doc/tutorial.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@ struct TimeBomb {
19091909
explosivity: uint
19101910
}
19111911
1912-
impl Drop for TimeBomb {
1912+
impl TimeBomb : Drop {
19131913
fn finalize(&self) {
19141914
for iter::repeat(self.explosivity) {
19151915
io::println("blam!");
@@ -1943,11 +1943,11 @@ and `&str`.
19431943

19441944
~~~~
19451945
# trait Printable { fn print(&self); }
1946-
impl Printable for int {
1946+
impl int: Printable {
19471947
fn print(&self) { io::println(fmt!("%d", *self)) }
19481948
}
19491949
1950-
impl Printable for &str {
1950+
impl &str: Printable {
19511951
fn print(&self) { io::println(*self) }
19521952
}
19531953
@@ -1966,7 +1966,7 @@ trait Seq<T> {
19661966
fn iter(&self, b: fn(v: &T));
19671967
}
19681968
1969-
impl<T> Seq<T> for ~[T] {
1969+
impl<T> ~[T]: Seq<T> {
19701970
fn len(&self) -> uint { vec::len(*self) }
19711971
fn iter(&self, b: fn(v: &T)) {
19721972
for vec::each(*self) |elt| { b(elt); }
@@ -1978,7 +1978,7 @@ The implementation has to explicitly declare the type parameter that
19781978
it binds, `T`, before using it to specify its trait type. Rust
19791979
requires this declaration because the `impl` could also, for example,
19801980
specify an implementation of `Seq<int>`. The trait type (appearing
1981-
between `impl` and `for`) *refers* to a type, rather than
1981+
after the colon in the `impl`) *refers* to a type, rather than
19821982
defining one.
19831983

19841984
The type parameters bound by a trait are in scope in each of the
@@ -2000,7 +2000,7 @@ trait Eq {
20002000
}
20012001
20022002
// In an impl, `self` refers just to the value of the receiver
2003-
impl Eq for int {
2003+
impl int: Eq {
20042004
fn equals(&self, other: &int) -> bool { *other == *self }
20052005
}
20062006
~~~~
@@ -2021,10 +2021,10 @@ trait Shape { static fn new(area: float) -> Self; }
20212021
struct Circle { radius: float }
20222022
struct Square { length: float }
20232023
2024-
impl Shape for Circle {
2024+
impl Circle: Shape {
20252025
static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
20262026
}
2027-
impl Shape for Square {
2027+
impl Square: Shape {
20282028
static fn new(area: float) -> Square { Square { length: sqrt(area) } }
20292029
}
20302030
@@ -2084,7 +2084,7 @@ However, consider this function:
20842084

20852085
~~~~
20862086
# type Circle = int; type Rectangle = int;
2087-
# impl Drawable for int { fn draw(&self) {} }
2087+
# impl int: Drawable { fn draw(&self) {} }
20882088
# fn new_circle() -> int { 1 }
20892089
trait Drawable { fn draw(&self); }
20902090
@@ -2120,8 +2120,9 @@ value to an object:
21202120
# fn new_rectangle() -> Rectangle { true }
21212121
# fn draw_all(shapes: &[@Drawable]) {}
21222122
2123-
impl Drawable for Circle { fn draw(&self) { ... } }
2124-
impl Drawable for Rectangle { fn draw(&self) { ... } }
2123+
impl Circle: Drawable { fn draw(&self) { ... } }
2124+
2125+
impl Rectangle: Drawable { fn draw(&self) { ... } }
21252126
21262127
let c: @Circle = @new_circle();
21272128
let r: @Rectangle = @new_rectangle();
@@ -2139,7 +2140,7 @@ for example, an `@Circle` may not be cast to an `~Drawable`.
21392140
~~~
21402141
# type Circle = int; type Rectangle = int;
21412142
# trait Drawable { fn draw(&self); }
2142-
# impl Drawable for int { fn draw(&self) {} }
2143+
# impl int: Drawable { fn draw(&self) {} }
21432144
# fn new_circle() -> int { 1 }
21442145
# fn new_rectangle() -> int { 2 }
21452146
// A managed object
@@ -2179,10 +2180,10 @@ Now, we can implement `Circle` on a type only if we also implement `Shape`.
21792180
# use float::sqrt;
21802181
# fn square(x: float) -> float { x * x }
21812182
struct CircleStruct { center: Point, radius: float }
2182-
impl Circle for CircleStruct {
2183+
impl CircleStruct: Circle {
21832184
fn radius(&self) -> float { sqrt(self.area() / pi) }
21842185
}
2185-
impl Shape for CircleStruct {
2186+
impl CircleStruct: Shape {
21862187
fn area(&self) -> float { pi * square(self.radius) }
21872188
}
21882189
~~~~
@@ -2214,8 +2215,8 @@ Likewise, supertrait methods may also be called on trait objects.
22142215
# use float::sqrt;
22152216
# struct Point { x: float, y: float }
22162217
# struct CircleStruct { center: Point, radius: float }
2217-
# impl Circle for CircleStruct { fn radius(&self) -> float { sqrt(self.area() / pi) } }
2218-
# impl Shape for CircleStruct { fn area(&self) -> float { pi * square(self.radius) } }
2218+
# impl CircleStruct: Circle { fn radius(&self) -> float { sqrt(self.area() / pi) } }
2219+
# impl CircleStruct: Shape { fn area(&self) -> float { pi * square(self.radius) } }
22192220
22202221
let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f};
22212222
let mycircle: Circle = concrete as @Circle;

0 commit comments

Comments
 (0)