about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2015-05-13 10:44:37 -0400
committerSteve Klabnik <steve@steveklabnik.com>2015-05-13 10:44:37 -0400
commit96a3443712849dbc6b82229bfab51b76f60a1c61 (patch)
tree8d8980a9d5f89849870354b4bb71474918e087a6
parenteb4cb6d16d142a4e810d1f1df0bab26542caa155 (diff)
downloadrust-96a3443712849dbc6b82229bfab51b76f60a1c61.tar.gz
rust-96a3443712849dbc6b82229bfab51b76f60a1c61.zip
Small cleanup to vec docs
Add the repeating form of the vec macro

Remove unneeded literal annotations.

Use more conventional variable names.
-rw-r--r--src/libcollections/vec.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 66bb84205e2..e35d81d3996 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -18,39 +18,41 @@
 //! You can explicitly create a `Vec<T>` with `new()`:
 //!
 //! ```
-//! let xs: Vec<i32> = Vec::new();
+//! let v: Vec<i32> = Vec::new();
 //! ```
 //!
 //! ...or by using the `vec!` macro:
 //!
 //! ```
-//! let ys: Vec<i32> = vec![];
+//! let v: Vec<i32> = vec![];
 //!
-//! let zs = vec![1i32, 2, 3, 4, 5];
+//! let v = vec![1, 2, 3, 4, 5];
+//!
+//! let v = vec![0; 10]; // ten zeroes
 //! ```
 //!
 //! You can `push` values onto the end of a vector (which will grow the vector as needed):
 //!
 //! ```
-//! let mut xs = vec![1i32, 2];
+//! let mut v = vec![1, 2];
 //!
-//! xs.push(3);
+//! v.push(3);
 //! ```
 //!
 //! Popping values works in much the same way:
 //!
 //! ```
-//! let mut xs = vec![1i32, 2];
+//! let mut v = vec![1, 2];
 //!
-//! let two = xs.pop();
+//! let two = v.pop();
 //! ```
 //!
 //! Vectors also support indexing (through the `Index` and `IndexMut` traits):
 //!
 //! ```
-//! let mut xs = vec![1i32, 2, 3];
-//! let three = xs[2];
-//! xs[1] = xs[1] + 5;
+//! let mut v = vec![1, 2, 3];
+//! let three = v[2];
+//! v[1] = v[1] + 5;
 //! ```
 
 #![stable(feature = "rust1", since = "1.0.0")]