Skip to content

Commit c74eb6a

Browse files
committed
---
yaml --- r: 23097 b: refs/heads/master c: 43c9c63 h: refs/heads/master i: 23095: a4216ba v: v3
1 parent d904f05 commit c74eb6a

File tree

3 files changed

+20
-36
lines changed

3 files changed

+20
-36
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: 6a0720b439a4692f55d3b9951e74d452a7aef802
2+
refs/heads/master: 43c9c637d345ca75ffec7583806ebd8b0520e31b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/doc/rust.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ type.
12991299

13001300
~~~~
13011301
# trait shape { }
1302-
# impl of shape for int { }
1302+
# impl int: shape { }
13031303
# let mycircle = 0;
13041304
13051305
let myshape: shape = mycircle as shape;
@@ -1325,7 +1325,7 @@ An _implementation item_ provides an implementation of a
13251325
13261326
type circle = {radius: float, center: point};
13271327
1328-
impl circle_shape of shape for circle {
1328+
impl circle: shape {
13291329
fn draw(s: surface) { do_draw_circle(s, self); }
13301330
fn bounding_box() -> bounding_box {
13311331
let r = self.radius;
@@ -1363,10 +1363,10 @@ specified, after the `impl` keyword.
13631363
~~~~
13641364
# trait seq<T> { }
13651365
1366-
impl <T> of seq<T> for ~[T] {
1366+
impl<T> ~[T]: seq<T> {
13671367
/* ... */
13681368
}
1369-
impl of seq<bool> for u32 {
1369+
impl u32: seq<bool> {
13701370
/* Treat the integer as a sequence of bits */
13711371
}
13721372
~~~~
@@ -2728,7 +2728,7 @@ trait printable {
27282728
fn to_str() -> ~str;
27292729
}
27302730
2731-
impl of printable for ~str {
2731+
impl ~str: printable {
27322732
fn to_str() -> ~str { self }
27332733
}
27342734
@@ -2775,7 +2775,7 @@ trait printable {
27752775
fn to_str() -> ~str;
27762776
}
27772777
2778-
impl of printable for ~str {
2778+
impl ~str: printable {
27792779
fn to_str() -> ~str { self }
27802780
}
27812781
~~~~~~

trunk/doc/tutorial.md

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Here's a parallel game of rock, paper, scissors to whet your appetite.
7474
~~~~
7575
use std;
7676
77-
import comm::{listen, methods};
77+
import comm::listen;
7878
import task::spawn;
7979
import iter::repeat;
8080
import rand::{seeded_rng, seed};
@@ -2440,10 +2440,10 @@ is used. This defines implementations of `to_str` for the `int` and
24402440

24412441
~~~~
24422442
# trait to_str { fn to_str() -> ~str; }
2443-
impl of to_str for int {
2443+
impl int: to_str {
24442444
fn to_str() -> ~str { int::to_str(self, 10u) }
24452445
}
2446-
impl of to_str for ~str {
2446+
impl ~str: to_str {
24472447
fn to_str() -> ~str { self }
24482448
}
24492449
~~~~
@@ -2454,22 +2454,6 @@ static overloading—when the Rust compiler sees the `to_str` method
24542454
call, it looks for an implementation that matches the type with a
24552455
method that matches the name, and simply calls that.
24562456

2457-
## Scoping
2458-
2459-
Implementations are not globally visible. Resolving a method to an
2460-
implementation requires that implementation to be in scope. You can
2461-
import and export implementations using the name of the trait they
2462-
implement (multiple implementations with the same name can be in scope
2463-
without problems). Or you can give them an explicit name if you
2464-
prefer, using this syntax:
2465-
2466-
~~~~
2467-
# trait to_str { fn to_str() -> ~str; }
2468-
impl nil_to_str of to_str for () {
2469-
fn to_str() -> ~str { ~"()" }
2470-
}
2471-
~~~~
2472-
24732457
## Bounded type parameters
24742458

24752459
The useful thing about value polymorphism is that it does not have to
@@ -2510,7 +2494,7 @@ trait seq<T> {
25102494
fn len() -> uint;
25112495
fn iter(fn(T));
25122496
}
2513-
impl <T> of seq<T> for ~[T] {
2497+
impl<T> ~[T]: seq<T> {
25142498
fn len() -> uint { vec::len(self) }
25152499
fn iter(b: fn(T)) {
25162500
for self.each |elt| { b(elt); }
@@ -2541,7 +2525,7 @@ trait eq {
25412525
fn equals(&&other: self) -> bool;
25422526
}
25432527
2544-
impl of eq for int {
2528+
impl int: eq {
25452529
fn equals(&&other: int) -> bool { other == self }
25462530
}
25472531
~~~~
@@ -2558,7 +2542,7 @@ However, consider this function:
25582542
~~~~
25592543
# type circle = int; type rectangle = int;
25602544
# trait drawable { fn draw(); }
2561-
# impl of drawable for int { fn draw() {} }
2545+
# impl int: drawable { fn draw() {} }
25622546
# fn new_circle() -> int { 1 }
25632547
fn draw_all<T: drawable>(shapes: ~[T]) {
25642548
for shapes.each |shape| { shape.draw(); }
@@ -2595,7 +2579,7 @@ to a trait type:
25952579
~~~~
25962580
# type circle = int; type rectangle = int;
25972581
# trait drawable { fn draw(); }
2598-
# impl of drawable for int { fn draw() {} }
2582+
# impl int: drawable { fn draw() {} }
25992583
# fn new_circle() -> int { 1 }
26002584
# fn new_rectangle() -> int { 2 }
26012585
# fn draw_all(shapes: ~[drawable]) {}
@@ -2909,7 +2893,7 @@ in parallel. We might write something like:
29092893

29102894
~~~~
29112895
import task::spawn;
2912-
import comm::{port, chan, methods};
2896+
import comm::{port, chan};
29132897
29142898
let port = port();
29152899
let chan = port.chan();
@@ -2939,7 +2923,7 @@ once it is complete. The second line creates a channel for sending
29392923
integers to the port `port`:
29402924

29412925
~~~~
2942-
# import comm::{port, chan, methods};
2926+
# import comm::{port, chan};
29432927
# let port = port::<int>();
29442928
let chan = port.chan();
29452929
~~~~
@@ -2949,7 +2933,7 @@ The next statement actually spawns the child:
29492933

29502934
~~~~
29512935
# import task::{spawn};
2952-
# import comm::{port, chan, methods};
2936+
# import comm::{port, chan};
29532937
# fn some_expensive_computation() -> int { 42 }
29542938
# let port = port();
29552939
# let chan = port.chan();
@@ -2969,7 +2953,7 @@ some other expensive computation and then waiting for the child's result
29692953
to arrive on the port:
29702954

29712955
~~~~
2972-
# import comm::{port, chan, methods};
2956+
# import comm::{port, chan};
29732957
# fn some_other_expensive_computation() {}
29742958
# let port = port::<int>();
29752959
# let chan = chan::<int>(port);
@@ -2991,7 +2975,7 @@ the string in response. The child terminates when `0` is received.
29912975
Here is the function that implements the child task:
29922976

29932977
~~~~
2994-
# import comm::{port, chan, methods};
2978+
# import comm::{port, chan};
29952979
fn stringifier(from_parent: port<uint>,
29962980
to_parent: chan<~str>) {
29972981
let mut value: uint;
@@ -3015,7 +2999,7 @@ Here is the code for the parent task:
30152999

30163000
~~~~
30173001
# import task::{spawn_conversation};
3018-
# import comm::{chan, port, methods};
3002+
# import comm::{chan, port};
30193003
# fn stringifier(from_parent: comm::port<uint>,
30203004
# to_parent: comm::chan<~str>) {
30213005
# comm::send(to_parent, ~"22");

0 commit comments

Comments
 (0)