diff options
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/rust.md | 12 | ||||
| -rw-r--r-- | src/doc/tutorial.md | 27 |
2 files changed, 16 insertions, 23 deletions
diff --git a/src/doc/rust.md b/src/doc/rust.md index b412fa4967d..ff2e2b52369 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -1335,7 +1335,7 @@ to pointers to the trait name, used as a type. # impl Shape for int { } # let mycircle = 0; -let myshape: @Shape = @mycircle as @Shape; +let myshape: ~Shape = ~mycircle as ~Shape; ~~~~ The resulting value is a managed box containing the value that was cast, @@ -1396,7 +1396,7 @@ Likewise, supertrait methods may also be called on trait objects. # impl Circle for int { fn radius(&self) -> f64 { 0.0 } } # let mycircle = 0; -let mycircle: Circle = @mycircle as @Circle; +let mycircle: Circle = ~mycircle as ~Circle; let nonsense = mycircle.radius() * mycircle.area(); ~~~~ @@ -3290,8 +3290,8 @@ Whereas most calls to trait methods are "early bound" (statically resolved) to s a call to a method on an object type is only resolved to a vtable entry at compile time. The actual implementation for each vtable entry can vary on an object-by-object basis. -Given a pointer-typed expression `E` of type `&T`, `~T` or `@T`, where `T` implements trait `R`, -casting `E` to the corresponding pointer type `&R`, `~R` or `@R` results in a value of the _object type_ `R`. +Given a pointer-typed expression `E` of type `&T` or `~T`, where `T` implements trait `R`, +casting `E` to the corresponding pointer type `&R` or `~R` results in a value of the _object type_ `R`. This result is represented as a pair of pointers: the vtable pointer for the `T` implementation of `R`, and the pointer value of `E`. @@ -3306,12 +3306,12 @@ impl Printable for int { fn to_string(&self) -> ~str { self.to_str() } } -fn print(a: @Printable) { +fn print(a: ~Printable) { println!("{}", a.to_string()); } fn main() { - print(@10 as @Printable); + print(~10 as ~Printable); } ~~~~ diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 7010eb4e48d..5d60b90a8f3 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -1857,7 +1857,7 @@ like any other function, except for the name `self`. The type of `self` is the type on which the method is implemented, or a pointer thereof. As an argument it is written either `self`, -`&self`, `@self`, or `~self`. +`&self`, or `~self`. A caller must in turn have a compatible pointer type to call the method. ~~~ @@ -1870,14 +1870,12 @@ A caller must in turn have a compatible pointer type to call the method. # } impl Shape { fn draw_reference(&self) { ... } - fn draw_managed(@self) { ... } fn draw_owned(~self) { ... } fn draw_value(self) { ... } } let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0); -(@s).draw_managed(); (~s).draw_owned(); (&s).draw_reference(); s.draw_value(); @@ -1897,7 +1895,6 @@ to a reference. # } # impl Shape { # fn draw_reference(&self) { ... } -# fn draw_managed(@self) { ... } # fn draw_owned(~self) { ... } # fn draw_value(self) { ... } # } @@ -2368,29 +2365,29 @@ an _object_. ~~~~ # trait Drawable { fn draw(&self); } -fn draw_all(shapes: &[@Drawable]) { +fn draw_all(shapes: &[~Drawable]) { for shape in shapes.iter() { shape.draw(); } } ~~~~ -In this example, there is no type parameter. Instead, the `@Drawable` -type denotes any managed box value that implements the `Drawable` -trait. To construct such a value, you use the `as` operator to cast a -value to an object: +In this example, there is no type parameter. Instead, the `~Drawable` +type denotes any owned box value that implements the `Drawable` trait. +To construct such a value, you use the `as` operator to cast a value +to an object: ~~~~ # type Circle = int; type Rectangle = bool; # trait Drawable { fn draw(&self); } # fn new_circle() -> Circle { 1 } # fn new_rectangle() -> Rectangle { true } -# fn draw_all(shapes: &[@Drawable]) {} +# fn draw_all(shapes: &[~Drawable]) {} impl Drawable for Circle { fn draw(&self) { ... } } impl Drawable for Rectangle { fn draw(&self) { ... } } -let c: @Circle = @new_circle(); -let r: @Rectangle = @new_rectangle(); -draw_all([c as @Drawable, r as @Drawable]); +let c: ~Circle = ~new_circle(); +let r: ~Rectangle = ~new_rectangle(); +draw_all([c as ~Drawable, r as ~Drawable]); ~~~~ We omit the code for `new_circle` and `new_rectangle`; imagine that @@ -2407,8 +2404,6 @@ for example, an `@Circle` may not be cast to an `~Drawable`. # impl Drawable for int { fn draw(&self) {} } # fn new_circle() -> int { 1 } # fn new_rectangle() -> int { 2 } -// A managed object -let boxy: @Drawable = @new_circle() as @Drawable; // An owned object let owny: ~Drawable = ~new_circle() as ~Drawable; // A borrowed object @@ -2427,7 +2422,6 @@ particular set of built-in kinds that their contents must fulfill in order to be packaged up in a trait object of that storage class. * The contents of owned traits (`~Trait`) must fulfill the `Send` bound. -* The contents of managed traits (`@Trait`) must fulfill the `'static` bound. * The contents of reference traits (`&Trait`) are not constrained by any bound. Consequently, the trait objects themselves automatically fulfill their @@ -2439,7 +2433,6 @@ to fulfilling `Send`, contents must also fulfill `Freeze`, and as a consequence, the trait itself fulfills `Freeze`. * `~Trait:Send` is equivalent to `~Trait`. -* `@Trait:'static` is equivalent to `@Trait`. * `&Trait:` is equivalent to `&Trait`. Builtin kind bounds can also be specified on closure types in the same way (for |
