Skip to content

Commit 0033a8b

Browse files
committed
Remove deprecated owned vector from complement cheatsheet.
1 parent cc45132 commit 0033a8b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/doc/complement-cheatsheet.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ To return a Borrowed String Slice (&str) use the str helper function
5353
~~~
5454
use std::str;
5555
56-
let bytes = ~[104u8,105u8];
57-
let x: Option<&str> = str::from_utf8(bytes);
58-
let y: &str = x.unwrap();
56+
let bytes = &[104u8,105u8];
57+
let x: &str = str::from_utf8(bytes).unwrap();
5958
~~~
6059

6160
To return an Owned String use the str helper function
@@ -136,7 +135,7 @@ let index: Option<uint> = str.find_str("rand");
136135
The [`Container`](../std/container/trait.Container.html) trait provides the `len` method.
137136

138137
~~~
139-
let u: ~[u32] = ~[0, 1, 2];
138+
let u: Vec<u32> = vec![0, 1, 2];
140139
let v: &[u32] = &[0, 1, 2, 3];
141140
let w: [u32, .. 5] = [0, 1, 2, 3, 4];
142141
@@ -148,7 +147,7 @@ println!("u: {}, v: {}, w: {}", u.len(), v.len(), w.len()); // 3, 4, 5
148147
Use the [`iter`](../std/vec/trait.ImmutableVector.html#tymethod.iter) method.
149148

150149
~~~
151-
let values: ~[int] = ~[1, 2, 3, 4, 5];
150+
let values: Vec<int> = vec![1, 2, 3, 4, 5];
152151
for value in values.iter() { // value: &int
153152
println!("{}", *value);
154153
}

0 commit comments

Comments
 (0)