diff options
| author | bors <bors@rust-lang.org> | 2014-05-31 01:06:40 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-05-31 01:06:40 -0700 |
| commit | faa7ba75a71b47151ed9b8c299d3fcc9af4207b5 (patch) | |
| tree | be5729412c9921961cdd4bc35c59107c6475acf1 /src/doc/tutorial.md | |
| parent | 92c43dba501be7df23a38842de2b12212212f49f (diff) | |
| parent | 1959925e514d9ecd5149435a3530dbdf0191f117 (diff) | |
| download | rust-faa7ba75a71b47151ed9b8c299d3fcc9af4207b5.tar.gz rust-faa7ba75a71b47151ed9b8c299d3fcc9af4207b5.zip | |
auto merge of #14553 : reem/rust/nuke-owned-vectors, r=alexcrichton
I removed all remaining deprecated owned vectors from the docs. All example tests pass.
Diffstat (limited to 'src/doc/tutorial.md')
| -rw-r--r-- | src/doc/tutorial.md | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index a4c89436d50..98cb3cd86fb 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2062,7 +2062,7 @@ extern crate collections; type Set<T> = collections::HashMap<T, ()>; struct Stack<T> { - elements: ~[T] + elements: Vec<T> } enum Option<T> { @@ -2320,7 +2320,7 @@ trait Seq<T> { fn length(&self) -> uint; } -impl<T> Seq<T> for ~[T] { +impl<T> Seq<T> for Vec<T> { fn length(&self) -> uint { self.len() } } ~~~~ @@ -2392,7 +2392,7 @@ generic types. ~~~~ # trait Printable { fn print(&self); } -fn print_all<T: Printable>(printable_things: ~[T]) { +fn print_all<T: Printable>(printable_things: Vec<T>) { for thing in printable_things.iter() { thing.print(); } @@ -2410,10 +2410,10 @@ as in this version of `print_all` that copies elements. ~~~ # trait Printable { fn print(&self); } -fn print_all<T: Printable + Clone>(printable_things: ~[T]) { +fn print_all<T: Printable + Clone>(printable_things: Vec<T>) { let mut i = 0; while i < printable_things.len() { - let copy_of_thing = printable_things[i].clone(); + let copy_of_thing = printable_things.get(i).clone(); copy_of_thing.print(); i += 1; } @@ -2438,11 +2438,11 @@ However, consider this function: # fn new_circle() -> int { 1 } trait Drawable { fn draw(&self); } -fn draw_all<T: Drawable>(shapes: ~[T]) { +fn draw_all<T: Drawable>(shapes: Vec<T>) { for shape in shapes.iter() { shape.draw(); } } # let c: Circle = new_circle(); -# draw_all(~[c]); +# draw_all(vec![c]); ~~~~ You can call that on a vector of circles, or a vector of rectangles @@ -2742,9 +2742,9 @@ mod farm { # pub type Chicken = int; # struct Human(int); # impl Human { pub fn rest(&self) { } } -# pub fn make_me_a_farm() -> Farm { Farm { chickens: ~[], farmer: Human(0) } } +# pub fn make_me_a_farm() -> Farm { Farm { chickens: vec![], farmer: Human(0) } } pub struct Farm { - chickens: ~[Chicken], + chickens: Vec<Chicken>, pub farmer: Human } |
