diff options
| author | Jonathan Reem <jonathan.reem@gmail.com> | 2014-05-30 18:49:48 -0700 |
|---|---|---|
| committer | Jonathan Reem <jonathan.reem@gmail.com> | 2014-05-30 21:30:18 -0700 |
| commit | 0033a8b269aebe9d88e5e4158ef2f0cdd630e92f (patch) | |
| tree | fa59cd479a947b939f629a544caf482c635e1491 | |
| parent | cc4513202d6f9c6896054ebaa1d99230b06e9f10 (diff) | |
| download | rust-0033a8b269aebe9d88e5e4158ef2f0cdd630e92f.tar.gz rust-0033a8b269aebe9d88e5e4158ef2f0cdd630e92f.zip | |
Remove deprecated owned vector from complement cheatsheet.
| -rw-r--r-- | src/doc/complement-cheatsheet.md | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/doc/complement-cheatsheet.md b/src/doc/complement-cheatsheet.md index f14b70afc7a..1c3352a829c 100644 --- a/src/doc/complement-cheatsheet.md +++ b/src/doc/complement-cheatsheet.md @@ -53,9 +53,8 @@ To return a Borrowed String Slice (&str) use the str helper function ~~~ use std::str; -let bytes = ~[104u8,105u8]; -let x: Option<&str> = str::from_utf8(bytes); -let y: &str = x.unwrap(); +let bytes = &[104u8,105u8]; +let x: &str = str::from_utf8(bytes).unwrap(); ~~~ To return an Owned String use the str helper function @@ -136,7 +135,7 @@ let index: Option<uint> = str.find_str("rand"); The [`Container`](../std/container/trait.Container.html) trait provides the `len` method. ~~~ -let u: ~[u32] = ~[0, 1, 2]; +let u: Vec<u32> = vec![0, 1, 2]; let v: &[u32] = &[0, 1, 2, 3]; let w: [u32, .. 5] = [0, 1, 2, 3, 4]; @@ -148,7 +147,7 @@ println!("u: {}, v: {}, w: {}", u.len(), v.len(), w.len()); // 3, 4, 5 Use the [`iter`](../std/vec/trait.ImmutableVector.html#tymethod.iter) method. ~~~ -let values: ~[int] = ~[1, 2, 3, 4, 5]; +let values: Vec<int> = vec![1, 2, 3, 4, 5]; for value in values.iter() { // value: &int println!("{}", *value); } |
