about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexis <a.beingessner@gmail.com>2015-02-12 16:45:07 -0500
committerAlexis Beingessner <a.beingessner@gmail.com>2015-02-13 14:12:51 -0500
commit1e75a05a0ed904cb311d117d2d65d222e20abdb2 (patch)
tree72fc33e29dde60abe2d6beb3b111ef3ca85c12ad
parentcca1cf613b8e535ab274d6ce5aecadf4708990bf (diff)
downloadrust-1e75a05a0ed904cb311d117d2d65d222e20abdb2.tar.gz
rust-1e75a05a0ed904cb311d117d2d65d222e20abdb2.zip
more int and cloned cleanup in collections
-rw-r--r--src/libcollections/binary_heap.rs2
-rw-r--r--src/libcollections/btree/map.rs2
-rw-r--r--src/libcollections/btree/set.rs54
-rw-r--r--src/libcollections/dlist.rs6
-rw-r--r--src/libcollections/fmt.rs12
-rw-r--r--src/libcollections/slice.rs4
-rw-r--r--src/libcollections/str.rs16
-rw-r--r--src/libcollections/vec.rs20
-rw-r--r--src/libstd/collections/hash/set.rs48
-rw-r--r--src/libstd/collections/mod.rs6
10 files changed, 85 insertions, 85 deletions
diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs
index 11576fbb00c..66374b639c1 100644
--- a/src/libcollections/binary_heap.rs
+++ b/src/libcollections/binary_heap.rs
@@ -255,7 +255,7 @@ impl<T: Ord> BinaryHeap<T> {
     ///
     /// // Print 1, 2, 3, 4 in arbitrary order
     /// for x in heap.into_iter() {
-    ///     // x has type int, not &int
+    ///     // x has type i32, not &i32
     ///     println!("{}", x);
     /// }
     /// ```
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 0e4a4002d6a..895fa076ab6 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -1783,7 +1783,7 @@ mod test {
     fn test_entry(){
         let xs = [(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)];
 
-        let mut map: BTreeMap<_, _> = xs.iter().map(|&x| x).collect();
+        let mut map: BTreeMap<_, _> = xs.iter().cloned().collect();
 
         // Existing key (insert)
         match map.entry(1) {
diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs
index 7cb31ab1f6d..8628879295b 100644
--- a/src/libcollections/btree/set.rs
+++ b/src/libcollections/btree/set.rs
@@ -89,7 +89,7 @@ impl<T: Ord> BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let mut set: BTreeSet<int> = BTreeSet::new();
+    /// let mut set: BTreeSet<i32> = BTreeSet::new();
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn new() -> BTreeSet<T> {
@@ -114,13 +114,13 @@ impl<T> BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let set: BTreeSet<usize> = [1, 2, 3, 4].iter().map(|&x| x).collect();
+    /// let set: BTreeSet<usize> = [1, 2, 3, 4].iter().cloned().collect();
     ///
     /// for x in set.iter() {
     ///     println!("{}", x);
     /// }
     ///
-    /// let v: Vec<usize> = set.iter().map(|&x| x).collect();
+    /// let v: Vec<usize> = set.iter().cloned().collect();
     /// assert_eq!(v, vec![1,2,3,4]);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -135,7 +135,7 @@ impl<T> BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let set: BTreeSet<usize> = [1, 2, 3, 4].iter().map(|&x| x).collect();
+    /// let set: BTreeSet<usize> = [1, 2, 3, 4].iter().cloned().collect();
     ///
     /// let v: Vec<usize> = set.into_iter().collect();
     /// assert_eq!(v, vec![1,2,3,4]);
@@ -331,7 +331,7 @@ impl<T: Ord> BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let set: BTreeSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
+    /// let set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
     /// assert_eq!(set.contains(&1), true);
     /// assert_eq!(set.contains(&4), false);
     /// ```
@@ -348,8 +348,8 @@ impl<T: Ord> BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let a: BTreeSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
-    /// let mut b: BTreeSet<int> = BTreeSet::new();
+    /// let a: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
+    /// let mut b = BTreeSet::new();
     ///
     /// assert_eq!(a.is_disjoint(&b), true);
     /// b.insert(4);
@@ -369,8 +369,8 @@ impl<T: Ord> BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let sup: BTreeSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
-    /// let mut set: BTreeSet<int> = BTreeSet::new();
+    /// let sup: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
+    /// let mut set = BTreeSet::new();
     ///
     /// assert_eq!(set.is_subset(&sup), true);
     /// set.insert(2);
@@ -411,8 +411,8 @@ impl<T: Ord> BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let sub: BTreeSet<int> = [1, 2].iter().map(|&x| x).collect();
-    /// let mut set: BTreeSet<int> = BTreeSet::new();
+    /// let sub: BTreeSet<_> = [1, 2].iter().cloned().collect();
+    /// let mut set = BTreeSet::new();
     ///
     /// assert_eq!(set.is_superset(&sub), false);
     ///
@@ -525,11 +525,11 @@ impl<'a, 'b, T: Ord + Clone> Sub<&'b BTreeSet<T>> for &'a BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let a: BTreeSet<int> = vec![1, 2, 3].into_iter().collect();
-    /// let b: BTreeSet<int> = vec![3, 4, 5].into_iter().collect();
+    /// let a: BTreeSet<_> = vec![1, 2, 3].into_iter().collect();
+    /// let b: BTreeSet<_> = vec![3, 4, 5].into_iter().collect();
     ///
-    /// let result: BTreeSet<int> = &a - &b;
-    /// let result_vec: Vec<int> = result.into_iter().collect();
+    /// let result = &a - &b;
+    /// let result_vec: Vec<_> = result.into_iter().collect();
     /// assert_eq!(result_vec, vec![1, 2]);
     /// ```
     fn sub(self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
@@ -548,11 +548,11 @@ impl<'a, 'b, T: Ord + Clone> BitXor<&'b BTreeSet<T>> for &'a BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let a: BTreeSet<int> = vec![1, 2, 3].into_iter().collect();
-    /// let b: BTreeSet<int> = vec![2, 3, 4].into_iter().collect();
+    /// let a: BTreeSet<_> = vec![1, 2, 3].into_iter().collect();
+    /// let b: BTreeSet<_> = vec![2, 3, 4].into_iter().collect();
     ///
-    /// let result: BTreeSet<int> = &a ^ &b;
-    /// let result_vec: Vec<int> = result.into_iter().collect();
+    /// let result = &a ^ &b;
+    /// let result_vec: Vec<_> = result.into_iter().collect();
     /// assert_eq!(result_vec, vec![1, 4]);
     /// ```
     fn bitxor(self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
@@ -571,11 +571,11 @@ impl<'a, 'b, T: Ord + Clone> BitAnd<&'b BTreeSet<T>> for &'a BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let a: BTreeSet<int> = vec![1, 2, 3].into_iter().collect();
-    /// let b: BTreeSet<int> = vec![2, 3, 4].into_iter().collect();
+    /// let a: BTreeSet<_> = vec![1, 2, 3].into_iter().collect();
+    /// let b: BTreeSet<_> = vec![2, 3, 4].into_iter().collect();
     ///
-    /// let result: BTreeSet<int> = &a & &b;
-    /// let result_vec: Vec<int> = result.into_iter().collect();
+    /// let result = &a & &b;
+    /// let result_vec: Vec<_> = result.into_iter().collect();
     /// assert_eq!(result_vec, vec![2, 3]);
     /// ```
     fn bitand(self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
@@ -594,11 +594,11 @@ impl<'a, 'b, T: Ord + Clone> BitOr<&'b BTreeSet<T>> for &'a BTreeSet<T> {
     /// ```
     /// use std::collections::BTreeSet;
     ///
-    /// let a: BTreeSet<int> = vec![1, 2, 3].into_iter().collect();
-    /// let b: BTreeSet<int> = vec![3, 4, 5].into_iter().collect();
+    /// let a: BTreeSet<_> = vec![1, 2, 3].into_iter().collect();
+    /// let b: BTreeSet<_> = vec![3, 4, 5].into_iter().collect();
     ///
-    /// let result: BTreeSet<int> = &a | &b;
-    /// let result_vec: Vec<int> = result.into_iter().collect();
+    /// let result = &a | &b;
+    /// let result_vec: Vec<_> = result.into_iter().collect();
     /// assert_eq!(result_vec, vec![1, 2, 3, 4, 5]);
     /// ```
     fn bitor(self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs
index a080146e0ec..356df24611b 100644
--- a/src/libcollections/dlist.rs
+++ b/src/libcollections/dlist.rs
@@ -756,7 +756,7 @@ impl<'a, A> IterMut<'a, A> {
     /// ```
     /// use std::collections::DList;
     ///
-    /// let mut list: DList<int> = vec![1, 3, 4].into_iter().collect();
+    /// let mut list: DList<_> = vec![1, 3, 4].into_iter().collect();
     ///
     /// {
     ///     let mut it = list.iter_mut();
@@ -765,7 +765,7 @@ impl<'a, A> IterMut<'a, A> {
     ///     it.insert_next(2);
     /// }
     /// {
-    ///     let vec: Vec<int> = list.into_iter().collect();
+    ///     let vec: Vec<_> = list.into_iter().collect();
     ///     assert_eq!(vec, vec![1, 2, 3, 4]);
     /// }
     /// ```
@@ -783,7 +783,7 @@ impl<'a, A> IterMut<'a, A> {
     /// ```
     /// use std::collections::DList;
     ///
-    /// let mut list: DList<int> = vec![1, 2, 3].into_iter().collect();
+    /// let mut list: DList<_> = vec![1, 2, 3].into_iter().collect();
     ///
     /// let mut it = list.iter_mut();
     /// assert_eq!(it.next().unwrap(), &1);
diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs
index 8f02f9fd580..0892a1c2008 100644
--- a/src/libcollections/fmt.rs
+++ b/src/libcollections/fmt.rs
@@ -108,7 +108,7 @@
 //! There are various parameters which do require a particular type, however.
 //! Namely if the syntax `{:.*}` is used, then the number of characters to print
 //! precedes the actual object being formatted, and the number of characters
-//! must have the type `uint`. Although a `uint` can be printed with `{}`, it is
+//! must have the type `usize`. Although a `usize` can be printed with `{}`, it is
 //! illegal to reference an argument as such. For example this is another
 //! invalid format string:
 //!
@@ -121,7 +121,7 @@
 //! When requesting that an argument be formatted with a particular type, you
 //! are actually requesting that an argument ascribes to a particular trait.
 //! This allows multiple actual types to be formatted via `{:x}` (like `i8` as
-//! well as `int`).  The current mapping of types to traits is:
+//! well as `isize`).  The current mapping of types to traits is:
 //!
 //! * *nothing* ⇒ `Display`
 //! * `?` ⇒ `Debug`
@@ -173,8 +173,8 @@
 //!
 //! #[derive(Debug)]
 //! struct Vector2D {
-//!     x: int,
-//!     y: int,
+//!     x: isize,
+//!     y: isize,
 //! }
 //!
 //! impl fmt::Display for Vector2D {
@@ -380,9 +380,9 @@
 //! the '0' flag is specified for numerics, then the implicit fill character is
 //! '0'.
 //!
-//! The value for the width can also be provided as a `uint` in the list of
+//! The value for the width can also be provided as a `usize` in the list of
 //! parameters by using the `2$` syntax indicating that the second argument is a
-//! `uint` specifying the width.
+//! `usize` specifying the width.
 //!
 //! ### Precision
 //!
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs
index b3f398b9cdf..945cceddfb5 100644
--- a/src/libcollections/slice.rs
+++ b/src/libcollections/slice.rs
@@ -73,7 +73,7 @@
 //!
 //! The method `iter()` returns an iteration value for a slice. The iterator
 //! yields references to the slice's elements, so if the element
-//! type of the slice is `int`, the element type of the iterator is `&int`.
+//! type of the slice is `isize`, the element type of the iterator is `&isize`.
 //!
 //! ```rust
 //! let numbers = [0, 1, 2];
@@ -1218,7 +1218,7 @@ impl Iterator for ElementSwaps {
         // Find the index of the largest mobile element:
         // The direction should point into the vector, and the
         // swap should be with a smaller `size` element.
-        let max = self.sdir.iter().map(|&x| x).enumerate()
+        let max = self.sdir.iter().cloned().enumerate()
                            .filter(|&(i, sd)|
                                 new_pos(i, sd.dir) < self.sdir.len() &&
                                 self.sdir[new_pos(i, sd.dir)].size < sd.size)
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index edb6d2de1c8..8382acfe3da 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -2705,22 +2705,22 @@ mod tests {
 
         for &(s, g) in &test_same[] {
             // test forward iterator
-            assert!(order::equals(s.graphemes(true), g.iter().map(|&x| x)));
-            assert!(order::equals(s.graphemes(false), g.iter().map(|&x| x)));
+            assert!(order::equals(s.graphemes(true), g.iter().cloned()));
+            assert!(order::equals(s.graphemes(false), g.iter().cloned()));
 
             // test reverse iterator
-            assert!(order::equals(s.graphemes(true).rev(), g.iter().rev().map(|&x| x)));
-            assert!(order::equals(s.graphemes(false).rev(), g.iter().rev().map(|&x| x)));
+            assert!(order::equals(s.graphemes(true).rev(), g.iter().rev().cloned()));
+            assert!(order::equals(s.graphemes(false).rev(), g.iter().rev().cloned()));
         }
 
         for &(s, gt, gf) in &test_diff {
             // test forward iterator
-            assert!(order::equals(s.graphemes(true), gt.iter().map(|&x| x)));
-            assert!(order::equals(s.graphemes(false), gf.iter().map(|&x| x)));
+            assert!(order::equals(s.graphemes(true), gt.iter().cloned()));
+            assert!(order::equals(s.graphemes(false), gf.iter().cloned()));
 
             // test reverse iterator
-            assert!(order::equals(s.graphemes(true).rev(), gt.iter().rev().map(|&x| x)));
-            assert!(order::equals(s.graphemes(false).rev(), gf.iter().rev().map(|&x| x)));
+            assert!(order::equals(s.graphemes(true).rev(), gt.iter().rev().cloned()));
+            assert!(order::equals(s.graphemes(false).rev(), gf.iter().rev().cloned()));
         }
 
         // test the indices iterators
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 341d91538ad..ad3adc0ddb5 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -158,7 +158,7 @@ impl<T> Vec<T> {
     /// # Examples
     ///
     /// ```
-    /// let mut vec: Vec<int> = Vec::new();
+    /// let mut vec: Vec<i32> = Vec::new();
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -277,7 +277,7 @@ impl<T> Vec<T> {
     /// # Examples
     ///
     /// ```
-    /// let vec: Vec<int> = Vec::with_capacity(10);
+    /// let vec: Vec<i32> = Vec::with_capacity(10);
     /// assert_eq!(vec.capacity(), 10);
     /// ```
     #[inline]
@@ -296,7 +296,7 @@ impl<T> Vec<T> {
     /// # Examples
     ///
     /// ```
-    /// let mut vec: Vec<int> = vec![1];
+    /// let mut vec = vec![1];
     /// vec.reserve(10);
     /// assert!(vec.capacity() >= 11);
     /// ```
@@ -325,7 +325,7 @@ impl<T> Vec<T> {
     /// # Examples
     ///
     /// ```
-    /// let mut vec: Vec<int> = vec![1];
+    /// let mut vec = vec![1];
     /// vec.reserve_exact(10);
     /// assert!(vec.capacity() >= 11);
     /// ```
@@ -347,7 +347,7 @@ impl<T> Vec<T> {
     /// # Examples
     ///
     /// ```
-    /// let mut vec: Vec<int> = Vec::with_capacity(10);
+    /// let mut vec = Vec::with_capacity(10);
     /// vec.push_all(&[1, 2, 3]);
     /// assert_eq!(vec.capacity(), 10);
     /// vec.shrink_to_fit();
@@ -424,7 +424,7 @@ impl<T> Vec<T> {
     /// # Examples
     ///
     /// ```
-    /// fn foo(slice: &mut [int]) {}
+    /// fn foo(slice: &mut [i32]) {}
     ///
     /// let mut vec = vec![1, 2];
     /// foo(vec.as_mut_slice());
@@ -845,7 +845,7 @@ impl<T> Vec<T> {
             // This `as isize` cast is safe, because the size of the elements of the
             // vector is not 0, and:
             //
-            // 1) If the size of the elements in the vector is 1, the `int` may
+            // 1) If the size of the elements in the vector is 1, the `isize` may
             //    overflow, but it has the correct bit pattern so that the
             //    `.offset()` function will work.
             //
@@ -858,7 +858,7 @@ impl<T> Vec<T> {
             //        (0x1 + 0x8 = 0x1 - 0x8)
             //
             // 2) If the size of the elements in the vector is >1, the `usize` ->
-            //    `int` conversion can't overflow.
+            //    `isize` conversion can't overflow.
             let offset = vec.len() as isize;
             let start = vec.as_mut_ptr();
 
@@ -1518,7 +1518,7 @@ impl<T> AsSlice<T> for Vec<T> {
     /// # Examples
     ///
     /// ```
-    /// fn foo(slice: &[int]) {}
+    /// fn foo(slice: &[i32]) {}
     ///
     /// let vec = vec![1, 2];
     /// foo(vec.as_slice());
@@ -2162,7 +2162,7 @@ mod tests {
     fn test_zip_unzip() {
         let z1 = vec![(1, 4), (2, 5), (3, 6)];
 
-        let (left, right): (Vec<_>, Vec<_>) = z1.iter().map(|&x| x).unzip();
+        let (left, right): (Vec<_>, Vec<_>) = z1.iter().cloned().unzip();
 
         assert_eq!((1, 4), (left[0], right[0]));
         assert_eq!((2, 5), (left[1], right[1]));
diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs
index de3c0424c9a..96af556dbcc 100644
--- a/src/libstd/collections/hash/set.rs
+++ b/src/libstd/collections/hash/set.rs
@@ -104,7 +104,7 @@ impl<T: Hash<Hasher> + Eq> HashSet<T, RandomState> {
     ///
     /// ```
     /// use std::collections::HashSet;
-    /// let mut set: HashSet<int> = HashSet::new();
+    /// let mut set: HashSet<i32> = HashSet::new();
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -119,7 +119,7 @@ impl<T: Hash<Hasher> + Eq> HashSet<T, RandomState> {
     ///
     /// ```
     /// use std::collections::HashSet;
-    /// let mut set: HashSet<int> = HashSet::with_capacity(10);
+    /// let mut set: HashSet<i32> = HashSet::with_capacity(10);
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -187,7 +187,7 @@ impl<T, S, H> HashSet<T, S>
     ///
     /// ```
     /// use std::collections::HashSet;
-    /// let set: HashSet<int> = HashSet::with_capacity(100);
+    /// let set: HashSet<i32> = HashSet::with_capacity(100);
     /// assert!(set.capacity() >= 100);
     /// ```
     #[inline]
@@ -208,7 +208,7 @@ impl<T, S, H> HashSet<T, S>
     ///
     /// ```
     /// use std::collections::HashSet;
-    /// let mut set: HashSet<int> = HashSet::new();
+    /// let mut set: HashSet<i32> = HashSet::new();
     /// set.reserve(10);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -225,7 +225,7 @@ impl<T, S, H> HashSet<T, S>
     /// ```
     /// use std::collections::HashSet;
     ///
-    /// let mut set: HashSet<int> = HashSet::with_capacity(100);
+    /// let mut set = HashSet::with_capacity(100);
     /// set.insert(1);
     /// set.insert(2);
     /// assert!(set.capacity() >= 100);
@@ -292,21 +292,21 @@ impl<T, S, H> HashSet<T, S>
     ///
     /// ```
     /// use std::collections::HashSet;
-    /// let a: HashSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
-    /// let b: HashSet<int> = [4, 2, 3, 4].iter().map(|&x| x).collect();
+    /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
+    /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
     ///
     /// // Can be seen as `a - b`.
     /// for x in a.difference(&b) {
     ///     println!("{}", x); // Print 1
     /// }
     ///
-    /// let diff: HashSet<int> = a.difference(&b).map(|&x| x).collect();
-    /// assert_eq!(diff, [1].iter().map(|&x| x).collect());
+    /// let diff: HashSet<_> = a.difference(&b).cloned().collect();
+    /// assert_eq!(diff, [1].iter().cloned().collect());
     ///
     /// // Note that difference is not symmetric,
     /// // and `b - a` means something else:
-    /// let diff: HashSet<int> = b.difference(&a).map(|&x| x).collect();
-    /// assert_eq!(diff, [4].iter().map(|&x| x).collect());
+    /// let diff: HashSet<_> = b.difference(&a).cloned().collect();
+    /// assert_eq!(diff, [4].iter().cloned().collect());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S> {
@@ -322,19 +322,19 @@ impl<T, S, H> HashSet<T, S>
     ///
     /// ```
     /// use std::collections::HashSet;
-    /// let a: HashSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
-    /// let b: HashSet<int> = [4, 2, 3, 4].iter().map(|&x| x).collect();
+    /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
+    /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
     ///
     /// // Print 1, 4 in arbitrary order.
     /// for x in a.symmetric_difference(&b) {
     ///     println!("{}", x);
     /// }
     ///
-    /// let diff1: HashSet<int> = a.symmetric_difference(&b).map(|&x| x).collect();
-    /// let diff2: HashSet<int> = b.symmetric_difference(&a).map(|&x| x).collect();
+    /// let diff1: HashSet<_> = a.symmetric_difference(&b).cloned().collect();
+    /// let diff2: HashSet<_> = b.symmetric_difference(&a).cloned().collect();
     ///
     /// assert_eq!(diff1, diff2);
-    /// assert_eq!(diff1, [1, 4].iter().map(|&x| x).collect());
+    /// assert_eq!(diff1, [1, 4].iter().cloned().collect());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn symmetric_difference<'a>(&'a self, other: &'a HashSet<T, S>)
@@ -348,16 +348,16 @@ impl<T, S, H> HashSet<T, S>
     ///
     /// ```
     /// use std::collections::HashSet;
-    /// let a: HashSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
-    /// let b: HashSet<int> = [4, 2, 3, 4].iter().map(|&x| x).collect();
+    /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
+    /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
     ///
     /// // Print 2, 3 in arbitrary order.
     /// for x in a.intersection(&b) {
     ///     println!("{}", x);
     /// }
     ///
-    /// let diff: HashSet<int> = a.intersection(&b).map(|&x| x).collect();
-    /// assert_eq!(diff, [2, 3].iter().map(|&x| x).collect());
+    /// let diff: HashSet<_> = a.intersection(&b).cloned().collect();
+    /// assert_eq!(diff, [2, 3].iter().cloned().collect());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S> {
@@ -373,16 +373,16 @@ impl<T, S, H> HashSet<T, S>
     ///
     /// ```
     /// use std::collections::HashSet;
-    /// let a: HashSet<int> = [1, 2, 3].iter().map(|&x| x).collect();
-    /// let b: HashSet<int> = [4, 2, 3, 4].iter().map(|&x| x).collect();
+    /// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
+    /// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
     ///
     /// // Print 1, 2, 3, 4 in arbitrary order.
     /// for x in a.union(&b) {
     ///     println!("{}", x);
     /// }
     ///
-    /// let diff: HashSet<int> = a.union(&b).map(|&x| x).collect();
-    /// assert_eq!(diff, [1, 2, 3, 4].iter().map(|&x| x).collect());
+    /// let diff: HashSet<_> = a.union(&b).cloned().collect();
+    /// assert_eq!(diff, [1, 2, 3, 4].iter().cloned().collect());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S> {
diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs
index 55924bc73a8..be441bfec88 100644
--- a/src/libstd/collections/mod.rs
+++ b/src/libstd/collections/mod.rs
@@ -65,8 +65,8 @@
 //! * You want a sorted map.
 //!
 //! ### Use a `VecMap` when:
-//! * You want a `HashMap` but with known to be small `uint` keys.
-//! * You want a `BTreeMap`, but with known to be small `uint` keys.
+//! * You want a `HashMap` but with known to be small `usize` keys.
+//! * You want a `BTreeMap`, but with known to be small `usize` keys.
 //!
 //! ### Use the `Set` variant of any of these `Map`s when:
 //! * You just want to remember which keys you've seen.
@@ -243,7 +243,7 @@
 //! use std::collections::RingBuf;
 //!
 //! let vec = vec![1, 2, 3, 4];
-//! let buf: RingBuf<uint> = vec.into_iter().collect();
+//! let buf: RingBuf<_> = vec.into_iter().collect();
 //! ```
 //!
 //! Iterators also provide a series of *adapter* methods for performing common tasks to