Skip to content

Commit 5e01573

Browse files
committed
---
yaml --- r: 46967 b: refs/heads/try c: bf27352 h: refs/heads/master i: 46965: 37a6b2c 46963: 3bfc66f 46959: f6608b0 v: v3
1 parent 73fc9e6 commit 5e01573

File tree

598 files changed

+1329
-1338
lines changed

Some content is hidden

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

598 files changed

+1329
-1338
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: afe73ccad916624c9ed9df18f49ab6f3ad9c9cb4
5+
refs/heads/try: bf27352953dba644568118a254ac4a3c3035daa0
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 int: Shape { }
1212+
# impl Shape for int { }
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 float: Num {
1236+
impl Num for float {
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 int: Shape { fn area() -> float { 0.0 } }
1273-
# impl int: Circle { fn radius() -> float { 0.0 } }
1272+
# impl Shape for int { fn area() -> float { 0.0 } }
1273+
# impl Circle for int { 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 Circle: Shape {
1295+
impl Shape for Circle {
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 Circle: Shape {
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 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.
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.
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> ~[T]: Seq<T> {
1323+
impl<T> Seq<T> for ~[T] {
13241324
...
13251325
}
1326-
impl u32: Seq<bool> {
1326+
impl Seq<bool> for u32 {
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 int: Printable {
2804+
impl Printable for int {
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 ~str: Printable {
2847+
impl Printable for ~str {
28482848
fn make_string() -> ~str { copy self }
28492849
}
28502850
~~~~~~~~

branches/try/doc/tutorial.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@ struct TimeBomb {
19091909
explosivity: uint
19101910
}
19111911
1912-
impl TimeBomb : Drop {
1912+
impl Drop for TimeBomb {
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 int: Printable {
1946+
impl Printable for int {
19471947
fn print(&self) { io::println(fmt!("%d", *self)) }
19481948
}
19491949
1950-
impl &str: Printable {
1950+
impl Printable for &str {
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> ~[T]: Seq<T> {
1969+
impl<T> Seq<T> for ~[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-
after the colon in the `impl`) *refers* to a type, rather than
1981+
between `impl` and `for`) *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 int: Eq {
2003+
impl Eq for int {
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 Circle: Shape {
2024+
impl Shape for Circle {
20252025
static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } }
20262026
}
2027-
impl Square: Shape {
2027+
impl Shape for Square {
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 int: Drawable { fn draw(&self) {} }
2087+
# impl Drawable for int { fn draw(&self) {} }
20882088
# fn new_circle() -> int { 1 }
20892089
trait Drawable { fn draw(&self); }
20902090
@@ -2120,9 +2120,8 @@ value to an object:
21202120
# fn new_rectangle() -> Rectangle { true }
21212121
# fn draw_all(shapes: &[@Drawable]) {}
21222122
2123-
impl Circle: Drawable { fn draw(&self) { ... } }
2124-
2125-
impl Rectangle: Drawable { fn draw(&self) { ... } }
2123+
impl Drawable for Circle { fn draw(&self) { ... } }
2124+
impl Drawable for Rectangle { fn draw(&self) { ... } }
21262125
21272126
let c: @Circle = @new_circle();
21282127
let r: @Rectangle = @new_rectangle();
@@ -2140,7 +2139,7 @@ for example, an `@Circle` may not be cast to an `~Drawable`.
21402139
~~~
21412140
# type Circle = int; type Rectangle = int;
21422141
# trait Drawable { fn draw(&self); }
2143-
# impl int: Drawable { fn draw(&self) {} }
2142+
# impl Drawable for int { fn draw(&self) {} }
21442143
# fn new_circle() -> int { 1 }
21452144
# fn new_rectangle() -> int { 2 }
21462145
// A managed object
@@ -2180,10 +2179,10 @@ Now, we can implement `Circle` on a type only if we also implement `Shape`.
21802179
# use float::sqrt;
21812180
# fn square(x: float) -> float { x * x }
21822181
struct CircleStruct { center: Point, radius: float }
2183-
impl CircleStruct: Circle {
2182+
impl Circle for CircleStruct {
21842183
fn radius(&self) -> float { sqrt(self.area() / pi) }
21852184
}
2186-
impl CircleStruct: Shape {
2185+
impl Shape for CircleStruct {
21872186
fn area(&self) -> float { pi * square(self.radius) }
21882187
}
21892188
~~~~
@@ -2215,8 +2214,8 @@ Likewise, supertrait methods may also be called on trait objects.
22152214
# use float::sqrt;
22162215
# struct Point { x: float, y: float }
22172216
# struct CircleStruct { center: Point, radius: float }
2218-
# impl CircleStruct: Circle { fn radius(&self) -> float { sqrt(self.area() / pi) } }
2219-
# impl CircleStruct: Shape { fn area(&self) -> float { pi * square(self.radius) } }
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) } }
22202219
22212220
let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f};
22222221
let mycircle: Circle = concrete as @Circle;

0 commit comments

Comments
 (0)