Skip to content

Commit 61371e5

Browse files
committed
---
yaml --- r: 53069 b: refs/heads/dist-snap c: 7a6db3f h: refs/heads/master i: 53067: fb3c300 v: v3
1 parent 74f0be3 commit 61371e5

File tree

5 files changed

+37
-39
lines changed

5 files changed

+37
-39
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 5a4695d407b63faae33c37499dc3c9bac43dfaf8
10+
refs/heads/dist-snap: 7a6db3f982cea9c5c1ed9921358988c1180851dc
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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/dist-snap/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;

branches/dist-snap/src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,11 @@ mod test {
227227
use super::*;
228228
use std::serialize::Encodable;
229229
use std;
230-
use core::dvec;
231230
use core::str;
232231
use util::testing::*;
233232

234233
#[test] fn to_json_str (val: Encodable<std::json::Encoder>) -> ~str {
235-
let bw = @io::BytesWriter {bytes: dvec::DVec(), pos: 0};
234+
let bw = @io::BytesWriter();
236235
val.encode(~std::json::Encoder(bw as io::Writer));
237236
str::from_bytes(bw.bytes.data)
238237
}

branches/dist-snap/src/libsyntax/parse/parser.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ use print::pprust::expr_to_str;
8484
use util::interner::Interner;
8585

8686
use core::cmp;
87-
use core::dvec::DVec;
88-
use core::dvec;
8987
use core::either::{Either, Left, Right};
9088
use core::either;
9189
use core::result::Result;
@@ -1323,11 +1321,11 @@ pub impl Parser {
13231321
}
13241322

13251323
fn parse_all_token_trees() -> ~[token_tree] {
1326-
let tts = DVec();
1324+
let mut tts = ~[];
13271325
while self.token != token::EOF {
13281326
tts.push(self.parse_token_tree());
13291327
}
1330-
tts.get()
1328+
tts
13311329
}
13321330

13331331
fn parse_matchers() -> ~[matcher] {
@@ -3954,7 +3952,7 @@ pub impl Parser {
39543952
VIEW_ITEMS_AND_ITEMS_ALLOWED | IMPORTS_AND_ITEMS_ALLOWED => false
39553953
};
39563954

3957-
let (view_items, items, foreign_items) = (DVec(), DVec(), DVec());
3955+
let mut (view_items, items, foreign_items) = (~[], ~[], ~[]);
39583956
loop {
39593957
match self.parse_item_or_view_item(attrs, items_allowed,
39603958
foreign_items_allowed,
@@ -3986,9 +3984,9 @@ pub impl Parser {
39863984
}
39873985

39883986
{attrs_remaining: attrs,
3989-
view_items: dvec::unwrap(move view_items),
3990-
items: dvec::unwrap(move items),
3991-
foreign_items: dvec::unwrap(move foreign_items)}
3987+
view_items: view_items,
3988+
items: items,
3989+
foreign_items: foreign_items}
39923990
}
39933991

39943992
// Parses a source module as a crate

0 commit comments

Comments
 (0)