summary refs log tree commit diff
path: root/src/libcollections/btree
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2015-11-24 11:23:48 +1300
committerNick Cameron <ncameron@mozilla.com>2015-11-24 11:53:47 +1300
commit0dfd875b6efa68ed67988a2f9856fc3bbdc91ce2 (patch)
tree4cbbfc1e2246c63f75e0d1f0e48d99153504b7b2 /src/libcollections/btree
parent1f1a1e6595cb9472927cd91d523982047832aa7a (diff)
downloadrust-0dfd875b6efa68ed67988a2f9856fc3bbdc91ce2.tar.gz
rust-0dfd875b6efa68ed67988a2f9856fc3bbdc91ce2.zip
rustfmt libcollections
Diffstat (limited to 'src/libcollections/btree')
-rw-r--r--src/libcollections/btree/map.rs415
-rw-r--r--src/libcollections/btree/node.rs333
-rw-r--r--src/libcollections/btree/set.rs204
3 files changed, 566 insertions, 386 deletions
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 178d7a4a052..0091beb9ca6 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -84,46 +84,46 @@ struct AbsIter<T> {
 /// An iterator over a BTreeMap's entries.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct Iter<'a, K: 'a, V: 'a> {
-    inner: AbsIter<Traversal<'a, K, V>>
+    inner: AbsIter<Traversal<'a, K, V>>,
 }
 
 /// A mutable iterator over a BTreeMap's entries.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct IterMut<'a, K: 'a, V: 'a> {
-    inner: AbsIter<MutTraversal<'a, K, V>>
+    inner: AbsIter<MutTraversal<'a, K, V>>,
 }
 
 /// An owning iterator over a BTreeMap's entries.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct IntoIter<K, V> {
-    inner: AbsIter<MoveTraversal<K, V>>
+    inner: AbsIter<MoveTraversal<K, V>>,
 }
 
 /// An iterator over a BTreeMap's keys.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct Keys<'a, K: 'a, V: 'a> {
-    inner: Map<Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>
+    inner: Map<Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>,
 }
 
 /// An iterator over a BTreeMap's values.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct Values<'a, K: 'a, V: 'a> {
-    inner: Map<Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
+    inner: Map<Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>,
 }
 
 /// An iterator over a sub-range of BTreeMap's entries.
 pub struct Range<'a, K: 'a, V: 'a> {
-    inner: AbsIter<Traversal<'a, K, V>>
+    inner: AbsIter<Traversal<'a, K, V>>,
 }
 
 /// A mutable iterator over a sub-range of BTreeMap's entries.
 pub struct RangeMut<'a, K: 'a, V: 'a> {
-    inner: AbsIter<MutTraversal<'a, K, V>>
+    inner: AbsIter<MutTraversal<'a, K, V>>,
 }
 
 /// A view into a single entry in a map, which may either be vacant or occupied.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub enum Entry<'a, K:'a, V:'a> {
+pub enum Entry<'a, K: 'a, V: 'a> {
     /// A vacant Entry
     #[stable(feature = "rust1", since = "1.0.0")]
     Vacant(VacantEntry<'a, K, V>),
@@ -135,14 +135,14 @@ pub enum Entry<'a, K:'a, V:'a> {
 
 /// A vacant Entry.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct VacantEntry<'a, K:'a, V:'a> {
+pub struct VacantEntry<'a, K: 'a, V: 'a> {
     key: K,
     stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
 }
 
 /// An occupied Entry.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct OccupiedEntry<'a, K:'a, V:'a> {
+pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
     stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>,
 }
 
@@ -151,7 +151,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[allow(deprecated)]
     pub fn new() -> BTreeMap<K, V> {
-        //FIXME(Gankro): Tune this as a function of size_of<K/V>?
+        // FIXME(Gankro): Tune this as a function of size_of<K/V>?
         BTreeMap::with_b(6)
     }
 
@@ -189,7 +189,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
     pub fn clear(&mut self) {
         let b = self.b;
         // avoid recursive destructors by manually traversing the tree
-        for _ in mem::replace(self, BTreeMap::with_b(b)) {};
+        for _ in mem::replace(self, BTreeMap::with_b(b)) {}
     }
 
     // Searching in a B-Tree is pretty straightforward.
@@ -216,16 +216,21 @@ impl<K: Ord, V> BTreeMap<K, V> {
     /// assert_eq!(map.get(&2), None);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where K: Borrow<Q>, Q: Ord {
+    pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>
+        where K: Borrow<Q>,
+              Q: Ord
+    {
         let mut cur_node = &self.root;
         loop {
             match Node::search(cur_node, key) {
                 Found(handle) => return Some(handle.into_kv().1),
-                GoDown(handle) => match handle.force() {
-                    Leaf(_) => return None,
-                    Internal(internal_handle) => {
-                        cur_node = internal_handle.into_edge();
-                        continue;
+                GoDown(handle) => {
+                    match handle.force() {
+                        Leaf(_) => return None,
+                        Internal(internal_handle) => {
+                            cur_node = internal_handle.into_edge();
+                            continue;
+                        }
                     }
                 }
             }
@@ -248,7 +253,10 @@ impl<K: Ord, V> BTreeMap<K, V> {
     /// assert_eq!(map.contains_key(&2), false);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where K: Borrow<Q>, Q: Ord {
+    pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
+        where K: Borrow<Q>,
+              Q: Ord
+    {
         self.get(key).is_some()
     }
 
@@ -271,18 +279,23 @@ impl<K: Ord, V> BTreeMap<K, V> {
     /// ```
     // See `get` for implementation notes, this is basically a copy-paste with mut's added
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V> where K: Borrow<Q>, Q: Ord {
+    pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V>
+        where K: Borrow<Q>,
+              Q: Ord
+    {
         // temp_node is a Borrowck hack for having a mutable value outlive a loop iteration
         let mut temp_node = &mut self.root;
         loop {
             let cur_node = temp_node;
             match Node::search(cur_node, key) {
                 Found(handle) => return Some(handle.into_kv_mut().1),
-                GoDown(handle) => match handle.force() {
-                    Leaf(_) => return None,
-                    Internal(internal_handle) => {
-                        temp_node = internal_handle.into_edge_mut();
-                        continue;
+                GoDown(handle) => {
+                    match handle.force() {
+                        Leaf(_) => return None,
+                        Internal(internal_handle) => {
+                            temp_node = internal_handle.into_edge_mut();
+                            continue;
+                        }
                     }
                 }
             }
@@ -366,7 +379,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
                         // Perfect match, swap the values and return the old one
                         mem::swap(handle.val_mut(), &mut value);
                         Finished(Some(value))
-                    },
+                    }
                     GoDown(handle) => {
                         // We need to keep searching, try to get the search stack
                         // to go down further
@@ -448,7 +461,10 @@ impl<K: Ord, V> BTreeMap<K, V> {
     /// assert_eq!(map.remove(&1), None);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V> where K: Borrow<Q>, Q: Ord {
+    pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V>
+        where K: Borrow<Q>,
+              Q: Ord
+    {
         // See `swap` for a more thorough description of the stuff going on in here
         let mut stack = stack::PartialSearchStack::new(self);
         loop {
@@ -457,20 +473,20 @@ impl<K: Ord, V> BTreeMap<K, V> {
                     Found(handle) => {
                         // Perfect match. Terminate the stack here, and remove the entry
                         Finished(Some(pusher.seal(handle).remove()))
-                    },
+                    }
                     GoDown(handle) => {
                         // We need to keep searching, try to go down the next edge
                         match handle.force() {
                             // We're at a leaf; the key isn't in here
                             Leaf(_) => Finished(None),
-                            Internal(internal_handle) => Continue(pusher.push(internal_handle))
+                            Internal(internal_handle) => Continue(pusher.push(internal_handle)),
                         }
                     }
                 }
             });
             match result {
                 Finished(ret) => return ret.map(|(_, v)| v),
-                Continue(new_stack) => stack = new_stack
+                Continue(new_stack) => stack = new_stack,
             }
         }
     }
@@ -505,7 +521,7 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
             inner: AbsIter {
                 traversals: lca,
                 size: len,
-            }
+            },
         }
     }
 }
@@ -534,7 +550,7 @@ impl<'a, K, V> IntoIterator for &'a mut BTreeMap<K, V> {
 /// return from a closure
 enum Continuation<A, B> {
     Continue(A),
-    Finished(B)
+    Finished(B),
 }
 
 /// The stack module provides a safe interface for constructing and manipulating a stack of ptrs
@@ -549,8 +565,7 @@ mod stack {
     use super::super::node::handle;
     use vec::Vec;
 
-    struct InvariantLifetime<'id>(
-        marker::PhantomData<::core::cell::Cell<&'id ()>>);
+    struct InvariantLifetime<'id>(marker::PhantomData<::core::cell::Cell<&'id ()>>);
 
     impl<'id> InvariantLifetime<'id> {
         fn new() -> InvariantLifetime<'id> {
@@ -585,7 +600,7 @@ mod stack {
     type Stack<K, V> = Vec<StackItem<K, V>>;
 
     /// A `PartialSearchStack` handles the construction of a search stack.
-    pub struct PartialSearchStack<'a, K:'a, V:'a> {
+    pub struct PartialSearchStack<'a, K: 'a, V: 'a> {
         map: &'a mut BTreeMap<K, V>,
         stack: Stack<K, V>,
         next: *mut Node<K, V>,
@@ -594,7 +609,7 @@ mod stack {
     /// A `SearchStack` represents a full path to an element or an edge of interest. It provides
     /// methods depending on the type of what the path points to for removing an element, inserting
     /// a new element, and manipulating to element at the top of the stack.
-    pub struct SearchStack<'a, K:'a, V:'a, Type, NodeType> {
+    pub struct SearchStack<'a, K: 'a, V: 'a, Type, NodeType> {
         map: &'a mut BTreeMap<K, V>,
         stack: Stack<K, V>,
         top: node::Handle<*mut Node<K, V>, Type, NodeType>,
@@ -603,7 +618,7 @@ mod stack {
     /// A `PartialSearchStack` that doesn't hold a reference to the next node, and is just
     /// just waiting for a `Handle` to that next node to be pushed. See `PartialSearchStack::with`
     /// for more details.
-    pub struct Pusher<'id, 'a, K:'a, V:'a> {
+    pub struct Pusher<'id, 'a, K: 'a, V: 'a> {
         map: &'a mut BTreeMap<K, V>,
         stack: Stack<K, V>,
         _marker: InvariantLifetime<'id>,
@@ -656,9 +671,8 @@ mod stack {
         /// Pushes the requested child of the stack's current top on top of the stack. If the child
         /// exists, then a new PartialSearchStack is yielded. Otherwise, a VacantSearchStack is
         /// yielded.
-        pub fn push(mut self, mut edge: node::Handle<IdRef<'id, Node<K, V>>,
-                                                     handle::Edge,
-                                                     handle::Internal>)
+        pub fn push(mut self,
+                    mut edge: node::Handle<IdRef<'id, Node<K, V>>, handle::Edge, handle::Internal>)
                     -> PartialSearchStack<'a, K, V> {
             self.stack.push(edge.as_raw());
             PartialSearchStack {
@@ -669,9 +683,11 @@ mod stack {
         }
 
         /// Converts the PartialSearchStack into a SearchStack.
-        pub fn seal<Type, NodeType>
-                   (self, mut handle: node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>)
-                    -> SearchStack<'a, K, V, Type, NodeType> {
+        pub fn seal<Type, NodeType>(self,
+                                    mut handle: node::Handle<IdRef<'id, Node<K, V>>,
+                                                             Type,
+                                                             NodeType>)
+                                    -> SearchStack<'a, K, V, Type, NodeType> {
             SearchStack {
                 map: self.map,
                 stack: self.stack,
@@ -694,9 +710,7 @@ mod stack {
         /// Converts the stack into a mutable reference to the value it points to, with a lifetime
         /// tied to the original tree.
         pub fn into_top(mut self) -> &'a mut V {
-            unsafe {
-                &mut *(self.top.from_raw_mut().val_mut() as *mut V)
-            }
+            unsafe { &mut *(self.top.from_raw_mut().val_mut() as *mut V) }
         }
     }
 
@@ -778,13 +792,13 @@ mod stack {
                         return SearchStack {
                             map: self.map,
                             stack: self.stack,
-                            top: leaf_handle.as_raw()
-                        }
+                            top: leaf_handle.as_raw(),
+                        };
                     }
                     Internal(mut internal_handle) => {
                         let mut right_handle = internal_handle.right_edge();
 
-                        //We're not a proper leaf stack, let's get to work.
+                        // We're not a proper leaf stack, let's get to work.
                         self.stack.push(right_handle.as_raw());
 
                         let mut temp_node = right_handle.edge_mut();
@@ -800,9 +814,9 @@ mod stack {
                                     return SearchStack {
                                         map: self.map,
                                         stack: self.stack,
-                                        top: handle.as_raw()
-                                    }
-                                },
+                                        top: handle.as_raw(),
+                                    };
+                                }
                                 Internal(kv_handle) => {
                                     // This node is internal, go deeper
                                     let mut handle = kv_handle.into_left_edge();
@@ -830,7 +844,8 @@ mod stack {
                 self.map.length += 1;
 
                 // Insert the key and value into the leaf at the top of the stack
-                let (mut insertion, inserted_ptr) = self.top.from_raw_mut()
+                let (mut insertion, inserted_ptr) = self.top
+                                                        .from_raw_mut()
                                                         .insert_as_leaf(key, val);
 
                 loop {
@@ -840,24 +855,29 @@ mod stack {
                             // inserting now.
                             return &mut *inserted_ptr;
                         }
-                        Split(key, val, right) => match self.stack.pop() {
-                            // The last insertion triggered a split, so get the next element on the
-                            // stack to recursively insert the split node into.
-                            None => {
-                                // The stack was empty; we've split the root, and need to make a
-                                // a new one. This is done in-place because we can't move the
-                                // root out of a reference to the tree.
-                                Node::make_internal_root(&mut self.map.root, self.map.b,
-                                                         key, val, right);
-
-                                self.map.depth += 1;
-                                return &mut *inserted_ptr;
-                            }
-                            Some(mut handle) => {
-                                // The stack wasn't empty, do the insertion and recurse
-                                insertion = handle.from_raw_mut()
-                                                  .insert_as_internal(key, val, right);
-                                continue;
+                        Split(key, val, right) => {
+                            match self.stack.pop() {
+                                // The last insertion triggered a split, so get the next element on
+                                // the stack to recursively insert the split node into.
+                                None => {
+                                    // The stack was empty; we've split the root, and need to make a
+                                    // a new one. This is done in-place because we can't move the
+                                    // root out of a reference to the tree.
+                                    Node::make_internal_root(&mut self.map.root,
+                                                             self.map.b,
+                                                             key,
+                                                             val,
+                                                             right);
+
+                                    self.map.depth += 1;
+                                    return &mut *inserted_ptr;
+                                }
+                                Some(mut handle) => {
+                                    // The stack wasn't empty, do the insertion and recurse
+                                    insertion = handle.from_raw_mut()
+                                                      .insert_as_internal(key, val, right);
+                                    continue;
+                                }
                             }
                         }
                     }
@@ -869,7 +889,7 @@ mod stack {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
-    fn from_iter<T: IntoIterator<Item=(K, V)>>(iter: T) -> BTreeMap<K, V> {
+    fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> BTreeMap<K, V> {
         let mut map = BTreeMap::new();
         map.extend(iter);
         map
@@ -879,7 +899,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
     #[inline]
-    fn extend<T: IntoIterator<Item=(K, V)>>(&mut self, iter: T) {
+    fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T) {
         for (k, v) in iter {
             self.insert(k, v);
         }
@@ -888,7 +908,7 @@ impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
 
 #[stable(feature = "extend_ref", since = "1.2.0")]
 impl<'a, K: Ord + Copy, V: Copy> Extend<(&'a K, &'a V)> for BTreeMap<K, V> {
-    fn extend<I: IntoIterator<Item=(&'a K, &'a V)>>(&mut self, iter: I) {
+    fn extend<I: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: I) {
         self.extend(iter.into_iter().map(|(&key, &value)| (key, value)));
     }
 }
@@ -912,8 +932,7 @@ impl<K: Ord, V> Default for BTreeMap<K, V> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<K: PartialEq, V: PartialEq> PartialEq for BTreeMap<K, V> {
     fn eq(&self, other: &BTreeMap<K, V>) -> bool {
-        self.len() == other.len() &&
-            self.iter().zip(other).all(|(a, b)| a == b)
+        self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a == b)
     }
 }
 
@@ -945,7 +964,8 @@ impl<K: Debug, V: Debug> Debug for BTreeMap<K, V> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap<K, V>
-    where K: Borrow<Q>, Q: Ord
+    where K: Borrow<Q>,
+          Q: Ord
 {
     type Output = V;
 
@@ -987,8 +1007,8 @@ enum StackOp<T> {
     Push(T),
     Pop,
 }
-impl<K, V, E, T> Iterator for AbsIter<T> where
-    T: DoubleEndedIterator<Item=TraversalItem<K, V, E>> + Traverse<E>,
+impl<K, V, E, T> Iterator for AbsIter<T>
+    where T: DoubleEndedIterator<Item = TraversalItem<K, V, E>> + Traverse<E>
 {
     type Item = (K, V);
 
@@ -1002,23 +1022,29 @@ impl<K, V, E, T> Iterator for AbsIter<T> where
             let op = match self.traversals.back_mut() {
                 None => return None,
                 // The queue wasn't empty, so continue along the node in its head
-                Some(iter) => match iter.next() {
-                    // The head is empty, so Pop it off and continue the process
-                    None => Pop,
-                    // The head yielded an edge, so make that the new head
-                    Some(Edge(next)) => Push(Traverse::traverse(next)),
-                    // The head yielded an entry, so yield that
-                    Some(Elem(kv)) => {
-                        self.size -= 1;
-                        return Some(kv)
+                Some(iter) => {
+                    match iter.next() {
+                        // The head is empty, so Pop it off and continue the process
+                        None => Pop,
+                        // The head yielded an edge, so make that the new head
+                        Some(Edge(next)) => Push(Traverse::traverse(next)),
+                        // The head yielded an entry, so yield that
+                        Some(Elem(kv)) => {
+                            self.size -= 1;
+                            return Some(kv);
+                        }
                     }
                 }
             };
 
             // Handle any operation as necessary, without a conflicting borrow of the queue
             match op {
-                Push(item) => { self.traversals.push_back(item); },
-                Pop => { self.traversals.pop_back(); },
+                Push(item) => {
+                    self.traversals.push_back(item);
+                }
+                Pop => {
+                    self.traversals.pop_back();
+                }
             }
         }
     }
@@ -1028,8 +1054,8 @@ impl<K, V, E, T> Iterator for AbsIter<T> where
     }
 }
 
-impl<K, V, E, T> DoubleEndedIterator for AbsIter<T> where
-    T: DoubleEndedIterator<Item=TraversalItem<K, V, E>> + Traverse<E>,
+impl<K, V, E, T> DoubleEndedIterator for AbsIter<T>
+    where T: DoubleEndedIterator<Item = TraversalItem<K, V, E>> + Traverse<E>
 {
     // next_back is totally symmetric to next
     #[inline]
@@ -1037,37 +1063,51 @@ impl<K, V, E, T> DoubleEndedIterator for AbsIter<T> where
         loop {
             let op = match self.traversals.front_mut() {
                 None => return None,
-                Some(iter) => match iter.next_back() {
-                    None => Pop,
-                    Some(Edge(next)) => Push(Traverse::traverse(next)),
-                    Some(Elem(kv)) => {
-                        self.size -= 1;
-                        return Some(kv)
+                Some(iter) => {
+                    match iter.next_back() {
+                        None => Pop,
+                        Some(Edge(next)) => Push(Traverse::traverse(next)),
+                        Some(Elem(kv)) => {
+                            self.size -= 1;
+                            return Some(kv);
+                        }
                     }
                 }
             };
 
             match op {
-                Push(item) => { self.traversals.push_front(item); },
-                Pop => { self.traversals.pop_front(); }
+                Push(item) => {
+                    self.traversals.push_front(item);
+                }
+                Pop => {
+                    self.traversals.pop_front();
+                }
             }
         }
     }
 }
 
 impl<'a, K, V> Clone for Iter<'a, K, V> {
-    fn clone(&self) -> Iter<'a, K, V> { Iter { inner: self.inner.clone() } }
+    fn clone(&self) -> Iter<'a, K, V> {
+        Iter { inner: self.inner.clone() }
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> Iterator for Iter<'a, K, V> {
     type Item = (&'a K, &'a V);
 
-    fn next(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() }
+    fn next(&mut self) -> Option<(&'a K, &'a V)> {
+        self.inner.next()
+    }
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.inner.size_hint()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> DoubleEndedIterator for Iter<'a, K, V> {
-    fn next_back(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next_back() }
+    fn next_back(&mut self) -> Option<(&'a K, &'a V)> {
+        self.inner.next_back()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> {}
@@ -1076,12 +1116,18 @@ impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> {}
 impl<'a, K, V> Iterator for IterMut<'a, K, V> {
     type Item = (&'a K, &'a mut V);
 
-    fn next(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() }
+    fn next(&mut self) -> Option<(&'a K, &'a mut V)> {
+        self.inner.next()
+    }
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.inner.size_hint()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> DoubleEndedIterator for IterMut<'a, K, V> {
-    fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next_back() }
+    fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> {
+        self.inner.next_back()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> {}
@@ -1090,70 +1136,102 @@ impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> {}
 impl<K, V> Iterator for IntoIter<K, V> {
     type Item = (K, V);
 
-    fn next(&mut self) -> Option<(K, V)> { self.inner.next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() }
+    fn next(&mut self) -> Option<(K, V)> {
+        self.inner.next()
+    }
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.inner.size_hint()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<K, V> DoubleEndedIterator for IntoIter<K, V> {
-    fn next_back(&mut self) -> Option<(K, V)> { self.inner.next_back() }
+    fn next_back(&mut self) -> Option<(K, V)> {
+        self.inner.next_back()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<K, V> ExactSizeIterator for IntoIter<K, V> {}
 
 impl<'a, K, V> Clone for Keys<'a, K, V> {
-    fn clone(&self) -> Keys<'a, K, V> { Keys { inner: self.inner.clone() } }
+    fn clone(&self) -> Keys<'a, K, V> {
+        Keys { inner: self.inner.clone() }
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> Iterator for Keys<'a, K, V> {
     type Item = &'a K;
 
-    fn next(&mut self) -> Option<(&'a K)> { self.inner.next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() }
+    fn next(&mut self) -> Option<(&'a K)> {
+        self.inner.next()
+    }
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.inner.size_hint()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> {
-    fn next_back(&mut self) -> Option<(&'a K)> { self.inner.next_back() }
+    fn next_back(&mut self) -> Option<(&'a K)> {
+        self.inner.next_back()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {}
 
 
 impl<'a, K, V> Clone for Values<'a, K, V> {
-    fn clone(&self) -> Values<'a, K, V> { Values { inner: self.inner.clone() } }
+    fn clone(&self) -> Values<'a, K, V> {
+        Values { inner: self.inner.clone() }
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> Iterator for Values<'a, K, V> {
     type Item = &'a V;
 
-    fn next(&mut self) -> Option<(&'a V)> { self.inner.next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() }
+    fn next(&mut self) -> Option<(&'a V)> {
+        self.inner.next()
+    }
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.inner.size_hint()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> {
-    fn next_back(&mut self) -> Option<(&'a V)> { self.inner.next_back() }
+    fn next_back(&mut self) -> Option<(&'a V)> {
+        self.inner.next_back()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {}
 
 impl<'a, K, V> Clone for Range<'a, K, V> {
-    fn clone(&self) -> Range<'a, K, V> { Range { inner: self.inner.clone() } }
+    fn clone(&self) -> Range<'a, K, V> {
+        Range { inner: self.inner.clone() }
+    }
 }
 impl<'a, K, V> Iterator for Range<'a, K, V> {
     type Item = (&'a K, &'a V);
 
-    fn next(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next() }
+    fn next(&mut self) -> Option<(&'a K, &'a V)> {
+        self.inner.next()
+    }
 }
 impl<'a, K, V> DoubleEndedIterator for Range<'a, K, V> {
-    fn next_back(&mut self) -> Option<(&'a K, &'a V)> { self.inner.next_back() }
+    fn next_back(&mut self) -> Option<(&'a K, &'a V)> {
+        self.inner.next_back()
+    }
 }
 
 impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
     type Item = (&'a K, &'a mut V);
 
-    fn next(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next() }
+    fn next(&mut self) -> Option<(&'a K, &'a mut V)> {
+        self.inner.next()
+    }
 }
 impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> {
-    fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> { self.inner.next_back() }
+    fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> {
+        self.inner.next_back()
+    }
 }
 
 impl<'a, K: Ord, V> Entry<'a, K, V> {
@@ -1251,7 +1329,7 @@ impl<K, V> BTreeMap<K, V> {
             inner: AbsIter {
                 traversals: lca,
                 size: len,
-            }
+            },
         }
     }
 
@@ -1283,7 +1361,7 @@ impl<K, V> BTreeMap<K, V> {
             inner: AbsIter {
                 traversals: lca,
                 size: len,
-            }
+            },
         }
     }
 
@@ -1303,7 +1381,9 @@ impl<K, V> BTreeMap<K, V> {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn keys<'a>(&'a self) -> Keys<'a, K, V> {
-        fn first<A, B>((a, _): (A, B)) -> A { a }
+        fn first<A, B>((a, _): (A, B)) -> A {
+            a
+        }
         let first: fn((&'a K, &'a V)) -> &'a K = first; // coerce to fn pointer
 
         Keys { inner: self.iter().map(first) }
@@ -1325,7 +1405,9 @@ impl<K, V> BTreeMap<K, V> {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn values<'a>(&'a self) -> Values<'a, K, V> {
-        fn second<A, B>((_, b): (A, B)) -> B { b }
+        fn second<A, B>((_, b): (A, B)) -> B {
+            b
+        }
         let second: fn((&'a K, &'a V)) -> &'a V = second; // coerce to fn pointer
 
         Values { inner: self.iter().map(second) }
@@ -1344,7 +1426,9 @@ impl<K, V> BTreeMap<K, V> {
     /// assert_eq!(a.len(), 1);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn len(&self) -> usize { self.length }
+    pub fn len(&self) -> usize {
+        self.length
+    }
 
     /// Returns true if the map contains no elements.
     ///
@@ -1359,7 +1443,9 @@ impl<K, V> BTreeMap<K, V> {
     /// assert!(!a.is_empty());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn is_empty(&self) -> bool { self.len() == 0 }
+    pub fn is_empty(&self) -> bool {
+        self.len() == 0
+    }
 }
 
 macro_rules! range_impl {
@@ -1518,12 +1604,20 @@ impl<K: Ord, V> BTreeMap<K, V> {
     #[unstable(feature = "btree_range",
                reason = "matches collection reform specification, waiting for dust to settle",
                issue = "27787")]
-    pub fn range<Min: ?Sized + Ord = K, Max: ?Sized + Ord = K>(&self, min: Bound<&Min>,
+    pub fn range<Min: ?Sized + Ord = K, Max: ?Sized + Ord = K>(&self,
+                                                               min: Bound<&Min>,
                                                                max: Bound<&Max>)
-        -> Range<K, V> where
-        K: Borrow<Min> + Borrow<Max>,
+                                                               -> Range<K, V>
+        where K: Borrow<Min> + Borrow<Max>
     {
-        range_impl!(&self.root, min, max, as_slices_internal, iter, Range, edges, [])
+        range_impl!(&self.root,
+                    min,
+                    max,
+                    as_slices_internal,
+                    iter,
+                    Range,
+                    edges,
+                    [])
     }
 
     /// Constructs a mutable double-ended iterator over a sub-range of elements in the map, starting
@@ -1552,13 +1646,20 @@ impl<K: Ord, V> BTreeMap<K, V> {
     #[unstable(feature = "btree_range",
                reason = "matches collection reform specification, waiting for dust to settle",
                issue = "27787")]
-    pub fn range_mut<Min: ?Sized + Ord = K, Max: ?Sized + Ord = K>(&mut self, min: Bound<&Min>,
+    pub fn range_mut<Min: ?Sized + Ord = K, Max: ?Sized + Ord = K>(&mut self,
+                                                                   min: Bound<&Min>,
                                                                    max: Bound<&Max>)
-        -> RangeMut<K, V> where
-        K: Borrow<Min> + Borrow<Max>,
+                                                                   -> RangeMut<K, V>
+        where K: Borrow<Min> + Borrow<Max>
     {
-        range_impl!(&mut self.root, min, max, as_slices_internal_mut, iter_mut, RangeMut,
-                                                                      edges_mut, [mut])
+        range_impl!(&mut self.root,
+                    min,
+                    max,
+                    as_slices_internal_mut,
+                    iter_mut,
+                    RangeMut,
+                    edges_mut,
+                    [mut])
     }
 
     /// Gets the given key's corresponding entry in the map for in-place manipulation.
@@ -1586,10 +1687,8 @@ impl<K: Ord, V> BTreeMap<K, V> {
                 match Node::search(node, &key) {
                     Found(handle) => {
                         // Perfect match
-                        Finished(Occupied(OccupiedEntry {
-                            stack: pusher.seal(handle)
-                        }))
-                    },
+                        Finished(Occupied(OccupiedEntry { stack: pusher.seal(handle) }))
+                    }
                     GoDown(handle) => {
                         match handle.force() {
                             Leaf(leaf_handle) => {
@@ -1597,12 +1696,9 @@ impl<K: Ord, V> BTreeMap<K, V> {
                                     stack: pusher.seal(leaf_handle),
                                     key: key,
                                 }))
-                            },
+                            }
                             Internal(internal_handle) => {
-                                Continue((
-                                    pusher.push(internal_handle),
-                                    key
-                                ))
+                                Continue((pusher.push(internal_handle), key))
                             }
                         }
                     }
@@ -1619,7 +1715,10 @@ impl<K: Ord, V> BTreeMap<K, V> {
     }
 }
 
-impl<K, Q: ?Sized> super::Recover<Q> for BTreeMap<K, ()> where K: Borrow<Q> + Ord, Q: Ord {
+impl<K, Q: ?Sized> super::Recover<Q> for BTreeMap<K, ()>
+    where K: Borrow<Q> + Ord,
+          Q: Ord
+{
     type Key = K;
 
     fn get(&self, key: &Q) -> Option<&K> {
@@ -1627,11 +1726,13 @@ impl<K, Q: ?Sized> super::Recover<Q> for BTreeMap<K, ()> where K: Borrow<Q> + Or
         loop {
             match Node::search(cur_node, key) {
                 Found(handle) => return Some(handle.into_kv().0),
-                GoDown(handle) => match handle.force() {
-                    Leaf(_) => return None,
-                    Internal(internal_handle) => {
-                        cur_node = internal_handle.into_edge();
-                        continue;
+                GoDown(handle) => {
+                    match handle.force() {
+                        Leaf(_) => return None,
+                        Internal(internal_handle) => {
+                            cur_node = internal_handle.into_edge();
+                            continue;
+                        }
                     }
                 }
             }
@@ -1648,20 +1749,20 @@ impl<K, Q: ?Sized> super::Recover<Q> for BTreeMap<K, ()> where K: Borrow<Q> + Or
                     Found(handle) => {
                         // Perfect match. Terminate the stack here, and remove the entry
                         Finished(Some(pusher.seal(handle).remove()))
-                    },
+                    }
                     GoDown(handle) => {
                         // We need to keep searching, try to go down the next edge
                         match handle.force() {
                             // We're at a leaf; the key isn't in here
                             Leaf(_) => Finished(None),
-                            Internal(internal_handle) => Continue(pusher.push(internal_handle))
+                            Internal(internal_handle) => Continue(pusher.push(internal_handle)),
                         }
                     }
                 }
             });
             match result {
                 Finished(ret) => return ret.map(|(k, _)| k),
-                Continue(new_stack) => stack = new_stack
+                Continue(new_stack) => stack = new_stack,
             }
         }
     }
@@ -1677,7 +1778,7 @@ impl<K, Q: ?Sized> super::Recover<Q> for BTreeMap<K, ()> where K: Borrow<Q> + Or
                     Found(mut handle) => {
                         mem::swap(handle.key_mut(), &mut key);
                         Finished(Some(key))
-                    },
+                    }
                     GoDown(handle) => {
                         match handle.force() {
                             Leaf(leaf_handle) => {
diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs
index dc4b7a1c3f7..26479b3f559 100644
--- a/src/libcollections/btree/node.rs
+++ b/src/libcollections/btree/node.rs
@@ -122,7 +122,8 @@ fn test_rounding() {
 // from the start of a mallocated array.
 #[inline]
 fn calculate_offsets(keys_size: usize,
-                     vals_size: usize, vals_align: usize,
+                     vals_size: usize,
+                     vals_align: usize,
                      edges_align: usize)
                      -> (usize, usize) {
     let vals_offset = round_up_to_next(keys_size, vals_align);
@@ -136,13 +137,14 @@ fn calculate_offsets(keys_size: usize,
 // Returns a tuple of (minimum required alignment, array_size),
 // from the start of a mallocated array.
 #[inline]
-fn calculate_allocation(keys_size: usize, keys_align: usize,
-                        vals_size: usize, vals_align: usize,
-                        edges_size: usize, edges_align: usize)
+fn calculate_allocation(keys_size: usize,
+                        keys_align: usize,
+                        vals_size: usize,
+                        vals_align: usize,
+                        edges_size: usize,
+                        edges_align: usize)
                         -> (usize, usize) {
-    let (_, edges_offset) = calculate_offsets(keys_size,
-                                              vals_size, vals_align,
-                                                         edges_align);
+    let (_, edges_offset) = calculate_offsets(keys_size, vals_size, vals_align, edges_align);
     let end_of_edges = edges_offset + edges_size;
 
     let min_align = cmp::max(keys_align, cmp::max(vals_align, edges_align));
@@ -171,14 +173,16 @@ fn calculate_allocation_generic<K, V>(capacity: usize, is_leaf: bool) -> (usize,
             (0, 1)
         }
     } else {
-        ((capacity + 1) * mem::size_of::<Node<K, V>>(), mem::align_of::<Node<K, V>>())
+        ((capacity + 1) * mem::size_of::<Node<K, V>>(),
+         mem::align_of::<Node<K, V>>())
     };
 
-    calculate_allocation(
-            keys_size, keys_align,
-            vals_size, vals_align,
-            edges_size, edges_align
-    )
+    calculate_allocation(keys_size,
+                         keys_align,
+                         vals_size,
+                         vals_align,
+                         edges_size,
+                         edges_align)
 }
 
 fn calculate_offsets_generic<K, V>(capacity: usize, is_leaf: bool) -> (usize, usize) {
@@ -191,11 +195,7 @@ fn calculate_offsets_generic<K, V>(capacity: usize, is_leaf: bool) -> (usize, us
         mem::align_of::<Node<K, V>>()
     };
 
-    calculate_offsets(
-            keys_size,
-            vals_size, vals_align,
-                       edges_align
-    )
+    calculate_offsets(keys_size, vals_size, vals_align, edges_align)
 }
 
 /// An iterator over a slice that owns the elements of the slice but not the allocation.
@@ -285,8 +285,7 @@ impl<K, V> Drop for Node<K, V> {
     #[unsafe_destructor_blind_to_params]
     fn drop(&mut self) {
         if self.keys.is_null() ||
-            (unsafe { self.keys.get() as *const K as usize == mem::POST_DROP_USIZE })
-        {
+           (unsafe { self.keys.get() as *const K as usize == mem::POST_DROP_USIZE }) {
             // Since we have #[unsafe_no_drop_flag], we have to watch
             // out for the sentinel value being stored in self.keys. (Using
             // null is technically a violation of the `Unique`
@@ -314,7 +313,9 @@ impl<K, V> Node<K, V> {
         let (alignment, size) = calculate_allocation_generic::<K, V>(capacity, false);
 
         let buffer = heap::allocate(size, alignment);
-        if buffer.is_null() { ::alloc::oom(); }
+        if buffer.is_null() {
+            ::alloc::oom();
+        }
 
         let (vals_offset, edges_offset) = calculate_offsets_generic::<K, V>(capacity, false);
 
@@ -332,7 +333,9 @@ impl<K, V> Node<K, V> {
         let (alignment, size) = calculate_allocation_generic::<K, V>(capacity, true);
 
         let buffer = unsafe { heap::allocate(size, alignment) };
-        if buffer.is_null() { ::alloc::oom(); }
+        if buffer.is_null() {
+            ::alloc::oom();
+        }
 
         let (vals_offset, _) = calculate_offsets_generic::<K, V>(capacity, true);
 
@@ -346,25 +349,25 @@ impl<K, V> Node<K, V> {
     }
 
     unsafe fn destroy(&mut self) {
-        let (alignment, size) =
-                calculate_allocation_generic::<K, V>(self.capacity(), self.is_leaf());
+        let (alignment, size) = calculate_allocation_generic::<K, V>(self.capacity(),
+                                                                     self.is_leaf());
         heap::deallocate(*self.keys as *mut u8, size, alignment);
     }
 
     #[inline]
     pub fn as_slices<'a>(&'a self) -> (&'a [K], &'a [V]) {
-        unsafe {(
-            slice::from_raw_parts(*self.keys, self.len()),
-            slice::from_raw_parts(*self.vals, self.len()),
-        )}
+        unsafe {
+            (slice::from_raw_parts(*self.keys, self.len()),
+             slice::from_raw_parts(*self.vals, self.len()))
+        }
     }
 
     #[inline]
     pub fn as_slices_mut<'a>(&'a mut self) -> (&'a mut [K], &'a mut [V]) {
-        unsafe {(
-            slice::from_raw_parts_mut(*self.keys, self.len()),
-            slice::from_raw_parts_mut(*self.vals, self.len()),
-        )}
+        unsafe {
+            (slice::from_raw_parts_mut(*self.keys, self.len()),
+             slice::from_raw_parts_mut(*self.vals, self.len()))
+        }
     }
 
     #[inline]
@@ -376,8 +379,8 @@ impl<K, V> Node<K, V> {
         } else {
             unsafe {
                 let data = match self.edges {
-                    None => heap::EMPTY as *const Node<K,V>,
-                    Some(ref p) => **p as *const Node<K,V>,
+                    None => heap::EMPTY as *const Node<K, V>,
+                    Some(ref p) => **p as *const Node<K, V>,
                 };
                 slice::from_raw_parts(data, self.len() + 1)
             }
@@ -403,8 +406,8 @@ impl<K, V> Node<K, V> {
         } else {
             unsafe {
                 let data = match self.edges {
-                    None => heap::EMPTY as *mut Node<K,V>,
-                    Some(ref mut p) => **p as *mut Node<K,V>,
+                    None => heap::EMPTY as *mut Node<K, V>,
+                    Some(ref mut p) => **p as *mut Node<K, V>,
                 };
                 slice::from_raw_parts_mut(data, len + 1)
             }
@@ -573,29 +576,49 @@ impl<K: Ord, V> Node<K, V> {
     /// Searches for the given key in the node. If it finds an exact match,
     /// `Found` will be yielded with the matching index. If it doesn't find an exact match,
     /// `GoDown` will be yielded with the index of the subtree the key must lie in.
-    pub fn search<Q: ?Sized, NodeRef: Deref<Target=Node<K, V>>>(node: NodeRef, key: &Q)
-                  -> SearchResult<NodeRef> where K: Borrow<Q>, Q: Ord {
+    pub fn search<Q: ?Sized, NodeRef: Deref<Target = Node<K, V>>>(node: NodeRef,
+                                                                  key: &Q)
+                                                                  -> SearchResult<NodeRef>
+        where K: Borrow<Q>,
+              Q: Ord
+    {
         // FIXME(Gankro): Tune when to search linear or binary based on B (and maybe K/V).
         // For the B configured as of this writing (B = 6), binary search was *significantly*
         // worse for usizes.
         match node.as_slices_internal().search_linear(key) {
-            (index, true) => Found(Handle { node: node, index: index, marker: PhantomData }),
-            (index, false) => GoDown(Handle { node: node, index: index, marker: PhantomData }),
+            (index, true) => {
+                Found(Handle {
+                    node: node,
+                    index: index,
+                    marker: PhantomData,
+                })
+            }
+            (index, false) => {
+                GoDown(Handle {
+                    node: node,
+                    index: index,
+                    marker: PhantomData,
+                })
+            }
         }
     }
 }
 
 // Public interface
-impl <K, V> Node<K, V> {
+impl<K, V> Node<K, V> {
     /// Make a leaf root from scratch
     pub fn make_leaf_root(b: usize) -> Node<K, V> {
         Node::new_leaf(capacity_from_b(b))
     }
 
     /// Make an internal root and swap it with an old root
-    pub fn make_internal_root(left_and_out: &mut Node<K,V>, b: usize, key: K, value: V,
-            right: Node<K,V>) {
-        let node = mem::replace(left_and_out, unsafe { Node::new_internal(capacity_from_b(b)) });
+    pub fn make_internal_root(left_and_out: &mut Node<K, V>,
+                              b: usize,
+                              key: K,
+                              value: V,
+                              right: Node<K, V>) {
+        let node = mem::replace(left_and_out,
+                                unsafe { Node::new_internal(capacity_from_b(b)) });
         left_and_out._len = 1;
         unsafe {
             ptr::write(left_and_out.keys_mut().get_unchecked_mut(0), key);
@@ -611,7 +634,9 @@ impl <K, V> Node<K, V> {
     }
 
     /// Does the node not contain any key-value pairs
-    pub fn is_empty(&self) -> bool { self.len() == 0 }
+    pub fn is_empty(&self) -> bool {
+        self.len() == 0
+    }
 
     /// How many key-value pairs the node can fit
     pub fn capacity(&self) -> usize {
@@ -634,7 +659,7 @@ impl <K, V> Node<K, V> {
     }
 }
 
-impl<K, V, NodeRef: Deref<Target=Node<K, V>>, Type, NodeType> Handle<NodeRef, Type, NodeType> {
+impl<K, V, NodeRef: Deref<Target = Node<K, V>>, Type, NodeType> Handle<NodeRef, Type, NodeType> {
     /// Returns a reference to the node that contains the pointed-to edge or key/value pair. This
     /// is very different from `edge` and `edge_mut` because those return children of the node
     /// returned by `node`.
@@ -643,8 +668,8 @@ impl<K, V, NodeRef: Deref<Target=Node<K, V>>, Type, NodeType> Handle<NodeRef, Ty
     }
 }
 
-impl<K, V, NodeRef, Type, NodeType> Handle<NodeRef, Type, NodeType> where
-    NodeRef: Deref<Target=Node<K, V>> + DerefMut,
+impl<K, V, NodeRef, Type, NodeType> Handle<NodeRef, Type, NodeType>
+    where NodeRef: Deref<Target = Node<K, V>> + DerefMut
 {
     /// Converts a handle into one that stores the same information using a raw pointer. This can
     /// be useful in conjunction with `from_raw` when the type system is insufficient for
@@ -687,9 +712,7 @@ impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, handle::Edge, handle::Internal> {
     /// returned pointer has a larger lifetime than what would be returned by `edge` or `edge_mut`,
     /// making it more suitable for moving down a chain of nodes.
     pub fn into_edge(self) -> &'a Node<K, V> {
-        unsafe {
-            self.node.edges().get_unchecked(self.index)
-        }
+        unsafe { self.node.edges().get_unchecked(self.index) }
     }
 }
 
@@ -698,13 +721,11 @@ impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, handle::Edge, handle::Internal
     /// because the returned pointer has a larger lifetime than what would be returned by
     /// `edge_mut`, making it more suitable for moving down a chain of nodes.
     pub fn into_edge_mut(self) -> &'a mut Node<K, V> {
-        unsafe {
-            self.node.edges_mut().get_unchecked_mut(self.index)
-        }
+        unsafe { self.node.edges_mut().get_unchecked_mut(self.index) }
     }
 }
 
-impl<K, V, NodeRef: Deref<Target=Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Internal> {
+impl<K, V, NodeRef: Deref<Target = Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Internal> {
     // This doesn't exist because there are no uses for it,
     // but is fine to add, analogous to edge_mut.
     //
@@ -715,10 +736,12 @@ impl<K, V, NodeRef: Deref<Target=Node<K, V>>> Handle<NodeRef, handle::Edge, hand
 
 pub enum ForceResult<NodeRef, Type> {
     Leaf(Handle<NodeRef, Type, handle::Leaf>),
-    Internal(Handle<NodeRef, Type, handle::Internal>)
+    Internal(Handle<NodeRef, Type, handle::Internal>),
 }
 
-impl<K, V, NodeRef: Deref<Target=Node<K, V>>, Type> Handle<NodeRef, Type, handle::LeafOrInternal> {
+impl<K, V, NodeRef: Deref<Target = Node<K, V>>, Type>
+    Handle<NodeRef, Type, handle::LeafOrInternal>
+{
     /// Figure out whether this handle is pointing to something in a leaf node or to something in
     /// an internal node, clarifying the type according to the result.
     pub fn force(self) -> ForceResult<NodeRef, Type> {
@@ -737,16 +760,15 @@ impl<K, V, NodeRef: Deref<Target=Node<K, V>>, Type> Handle<NodeRef, Type, handle
         }
     }
 }
-impl<K, V, NodeRef> Handle<NodeRef, handle::Edge, handle::Leaf> where
-    NodeRef: Deref<Target=Node<K, V>> + DerefMut,
+impl<K, V, NodeRef> Handle<NodeRef, handle::Edge, handle::Leaf>
+    where NodeRef: Deref<Target = Node<K, V>> + DerefMut
 {
     /// Tries to insert this key-value pair at the given index in this leaf node
     /// If the node is full, we have to split it.
     ///
     /// Returns a *mut V to the inserted value, because the caller may want this when
     /// they're done mutating the tree, but we don't want to borrow anything for now.
-    pub fn insert_as_leaf(mut self, key: K, value: V) ->
-            (InsertionResult<K, V>, *mut V) {
+    pub fn insert_as_leaf(mut self, key: K, value: V) -> (InsertionResult<K, V>, *mut V) {
         if !self.node.is_full() {
             // The element can fit, just insert it
             (Fit, unsafe { self.node.insert_kv(self.index, key, value) as *mut _ })
@@ -771,21 +793,22 @@ impl<K, V, NodeRef> Handle<NodeRef, handle::Edge, handle::Leaf> where
     }
 }
 
-impl<K, V, NodeRef> Handle<NodeRef, handle::Edge, handle::Internal> where
-    NodeRef: Deref<Target=Node<K, V>> + DerefMut,
+impl<K, V, NodeRef> Handle<NodeRef, handle::Edge, handle::Internal>
+    where NodeRef: Deref<Target = Node<K, V>> + DerefMut
 {
     /// Returns a mutable reference to the edge pointed-to by this handle. This should not be
     /// confused with `node`, which references the parent node of what is returned here.
     pub fn edge_mut(&mut self) -> &mut Node<K, V> {
-        unsafe {
-            self.node.edges_mut().get_unchecked_mut(self.index)
-        }
+        unsafe { self.node.edges_mut().get_unchecked_mut(self.index) }
     }
 
     /// Tries to insert this key-value pair at the given index in this internal node
     /// If the node is full, we have to split it.
-    pub fn insert_as_internal(mut self, key: K, value: V, right: Node<K, V>)
-            -> InsertionResult<K, V> {
+    pub fn insert_as_internal(mut self,
+                              key: K,
+                              value: V,
+                              right: Node<K, V>)
+                              -> InsertionResult<K, V> {
         if !self.node.is_full() {
             // The element can fit, just insert it
             unsafe {
@@ -856,8 +879,8 @@ impl<K, V, NodeRef> Handle<NodeRef, handle::Edge, handle::Internal> where
     }
 }
 
-impl<K, V, NodeRef, NodeType> Handle<NodeRef, handle::Edge, NodeType> where
-    NodeRef: Deref<Target=Node<K, V>> + DerefMut,
+impl<K, V, NodeRef, NodeType> Handle<NodeRef, handle::Edge, NodeType>
+    where NodeRef: Deref<Target = Node<K, V>> + DerefMut
 {
     /// Gets the handle pointing to the key/value pair just to the left of the pointed-to edge.
     /// This is unsafe because the handle might point to the first edge in the node, which has no
@@ -889,10 +912,8 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, handle::KV, NodeType> {
     pub fn into_kv(self) -> (&'a K, &'a V) {
         let (keys, vals) = self.node.as_slices();
         unsafe {
-            (
-                keys.get_unchecked(self.index),
-                vals.get_unchecked(self.index)
-            )
+            (keys.get_unchecked(self.index),
+             vals.get_unchecked(self.index))
         }
     }
 }
@@ -904,10 +925,8 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, handle::KV, NodeType
     pub fn into_kv_mut(self) -> (&'a mut K, &'a mut V) {
         let (keys, vals) = self.node.as_slices_mut();
         unsafe {
-            (
-                keys.get_unchecked_mut(self.index),
-                vals.get_unchecked_mut(self.index)
-            )
+            (keys.get_unchecked_mut(self.index),
+             vals.get_unchecked_mut(self.index))
         }
     }
 
@@ -923,8 +942,10 @@ impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, handle::KV, NodeType
     }
 }
 
-impl<'a, K: 'a, V: 'a, NodeRef: Deref<Target=Node<K, V>> + 'a, NodeType> Handle<NodeRef, handle::KV,
-                                                                         NodeType> {
+
+impl<'a, K: 'a, V: 'a, NodeRef: Deref<Target = Node<K, V>> + 'a, NodeType> Handle<NodeRef,
+                                                                                  handle::KV,
+                                                                                  NodeType> {
     // These are fine to include, but are currently unneeded.
     //
     // /// Returns a reference to the key pointed-to by this handle. This doesn't return a
@@ -942,8 +963,8 @@ impl<'a, K: 'a, V: 'a, NodeRef: Deref<Target=Node<K, V>> + 'a, NodeType> Handle<
     // }
 }
 
-impl<'a, K: 'a, V: 'a, NodeRef, NodeType> Handle<NodeRef, handle::KV, NodeType> where
-    NodeRef: 'a + Deref<Target=Node<K, V>> + DerefMut,
+impl<'a, K: 'a, V: 'a, NodeRef, NodeType> Handle<NodeRef, handle::KV, NodeType>
+    where NodeRef: 'a + Deref<Target = Node<K, V>> + DerefMut
 {
     /// Returns a mutable reference to the key pointed-to by this handle. This doesn't return a
     /// reference with a lifetime as large as `into_kv_mut`, but it also does not consume the
@@ -960,8 +981,8 @@ impl<'a, K: 'a, V: 'a, NodeRef, NodeType> Handle<NodeRef, handle::KV, NodeType>
     }
 }
 
-impl<K, V, NodeRef, NodeType> Handle<NodeRef, handle::KV, NodeType> where
-    NodeRef: Deref<Target=Node<K, V>> + DerefMut,
+impl<K, V, NodeRef, NodeType> Handle<NodeRef, handle::KV, NodeType>
+    where NodeRef: Deref<Target = Node<K, V>> + DerefMut
 {
     /// Gets the handle pointing to the edge immediately to the left of the key/value pair pointed
     /// to by this handle.
@@ -984,8 +1005,8 @@ impl<K, V, NodeRef, NodeType> Handle<NodeRef, handle::KV, NodeType> where
     }
 }
 
-impl<K, V, NodeRef> Handle<NodeRef, handle::KV, handle::Leaf> where
-    NodeRef: Deref<Target=Node<K, V>> + DerefMut,
+impl<K, V, NodeRef> Handle<NodeRef, handle::KV, handle::Leaf>
+    where NodeRef: Deref<Target = Node<K, V>> + DerefMut
 {
     /// Removes the key/value pair at the handle's location.
     ///
@@ -997,8 +1018,8 @@ impl<K, V, NodeRef> Handle<NodeRef, handle::KV, handle::Leaf> where
     }
 }
 
-impl<K, V, NodeRef> Handle<NodeRef, handle::KV, handle::Internal> where
-    NodeRef: Deref<Target=Node<K, V>> + DerefMut
+impl<K, V, NodeRef> Handle<NodeRef, handle::KV, handle::Internal>
+    where NodeRef: Deref<Target = Node<K, V>> + DerefMut
 {
     /// Steal! Stealing is roughly analogous to a binary tree rotation.
     /// In this case, we're "rotating" right.
@@ -1071,7 +1092,8 @@ impl<K, V, NodeRef> Handle<NodeRef, handle::KV, handle::Internal> where
         let right = self.node.remove_edge(self.index + 1);
 
         // Give left right's stuff.
-        self.left_edge().edge_mut()
+        self.left_edge()
+            .edge_mut()
             .absorb(key, val, right);
     }
 }
@@ -1082,8 +1104,9 @@ impl<K, V> Node<K, V> {
     /// # Panics (in debug build)
     ///
     /// Panics if the given index is out of bounds.
-    pub fn kv_handle(&mut self, index: usize) -> Handle<&mut Node<K, V>, handle::KV,
-                                                       handle::LeafOrInternal> {
+    pub fn kv_handle(&mut self,
+                     index: usize)
+                     -> Handle<&mut Node<K, V>, handle::KV, handle::LeafOrInternal> {
         // Necessary for correctness, but in a private module
         debug_assert!(index < self.len(), "kv_handle index out of bounds");
         Handle {
@@ -1111,7 +1134,7 @@ impl<K, V> Node<K, V> {
 
                     ptr: Unique::new(*self.keys as *mut u8),
                     capacity: self.capacity(),
-                    is_leaf: self.is_leaf()
+                    is_leaf: self.is_leaf(),
                 },
                 head_is_edge: true,
                 tail_is_edge: true,
@@ -1160,16 +1183,12 @@ impl<K, V> Node<K, V> {
     // This must be followed by insert_edge on an internal node.
     #[inline]
     unsafe fn insert_kv(&mut self, index: usize, key: K, val: V) -> &mut V {
-        ptr::copy(
-            self.keys().as_ptr().offset(index as isize),
-            self.keys_mut().as_mut_ptr().offset(index as isize + 1),
-            self.len() - index
-        );
-        ptr::copy(
-            self.vals().as_ptr().offset(index as isize),
-            self.vals_mut().as_mut_ptr().offset(index as isize + 1),
-            self.len() - index
-        );
+        ptr::copy(self.keys().as_ptr().offset(index as isize),
+                  self.keys_mut().as_mut_ptr().offset(index as isize + 1),
+                  self.len() - index);
+        ptr::copy(self.vals().as_ptr().offset(index as isize),
+                  self.vals_mut().as_mut_ptr().offset(index as isize + 1),
+                  self.len() - index);
 
         ptr::write(self.keys_mut().get_unchecked_mut(index), key);
         ptr::write(self.vals_mut().get_unchecked_mut(index), val);
@@ -1182,11 +1201,9 @@ impl<K, V> Node<K, V> {
     // This can only be called immediately after a call to insert_kv.
     #[inline]
     unsafe fn insert_edge(&mut self, index: usize, edge: Node<K, V>) {
-        ptr::copy(
-            self.edges().as_ptr().offset(index as isize),
-            self.edges_mut().as_mut_ptr().offset(index as isize + 1),
-            self.len() - index
-        );
+        ptr::copy(self.edges().as_ptr().offset(index as isize),
+                  self.edges_mut().as_mut_ptr().offset(index as isize + 1),
+                  self.len() - index);
         ptr::write(self.edges_mut().get_unchecked_mut(index), edge);
     }
 
@@ -1215,16 +1232,12 @@ impl<K, V> Node<K, V> {
         let key = ptr::read(self.keys().get_unchecked(index));
         let val = ptr::read(self.vals().get_unchecked(index));
 
-        ptr::copy(
-            self.keys().as_ptr().offset(index as isize + 1),
-            self.keys_mut().as_mut_ptr().offset(index as isize),
-            self.len() - index - 1
-        );
-        ptr::copy(
-            self.vals().as_ptr().offset(index as isize + 1),
-            self.vals_mut().as_mut_ptr().offset(index as isize),
-            self.len() - index - 1
-        );
+        ptr::copy(self.keys().as_ptr().offset(index as isize + 1),
+                  self.keys_mut().as_mut_ptr().offset(index as isize),
+                  self.len() - index - 1);
+        ptr::copy(self.vals().as_ptr().offset(index as isize + 1),
+                  self.vals_mut().as_mut_ptr().offset(index as isize),
+                  self.len() - index - 1);
 
         self._len -= 1;
 
@@ -1236,12 +1249,10 @@ impl<K, V> Node<K, V> {
     unsafe fn remove_edge(&mut self, index: usize) -> Node<K, V> {
         let edge = ptr::read(self.edges().get_unchecked(index));
 
-        ptr::copy(
-            self.edges().as_ptr().offset(index as isize + 1),
-            self.edges_mut().as_mut_ptr().offset(index as isize),
-            // index can be == len+1, so do the +1 first to avoid underflow.
-            (self.len() + 1) - index
-        );
+        ptr::copy(self.edges().as_ptr().offset(index as isize + 1),
+                  self.edges_mut().as_mut_ptr().offset(index as isize),
+                  // index can be == len+1, so do the +1 first to avoid underflow.
+                  (self.len() + 1) - index);
 
         edge
     }
@@ -1264,22 +1275,16 @@ impl<K, V> Node<K, V> {
         unsafe {
             right._len = self.len() / 2;
             let right_offset = self.len() - right.len();
-            ptr::copy_nonoverlapping(
-                self.keys().as_ptr().offset(right_offset as isize),
-                right.keys_mut().as_mut_ptr(),
-                right.len()
-            );
-            ptr::copy_nonoverlapping(
-                self.vals().as_ptr().offset(right_offset as isize),
-                right.vals_mut().as_mut_ptr(),
-                right.len()
-            );
+            ptr::copy_nonoverlapping(self.keys().as_ptr().offset(right_offset as isize),
+                                     right.keys_mut().as_mut_ptr(),
+                                     right.len());
+            ptr::copy_nonoverlapping(self.vals().as_ptr().offset(right_offset as isize),
+                                     right.vals_mut().as_mut_ptr(),
+                                     right.len());
             if !self.is_leaf() {
-                ptr::copy_nonoverlapping(
-                    self.edges().as_ptr().offset(right_offset as isize),
-                    right.edges_mut().as_mut_ptr(),
-                    right.len() + 1
-                );
+                ptr::copy_nonoverlapping(self.edges().as_ptr().offset(right_offset as isize),
+                                         right.edges_mut().as_mut_ptr(),
+                                         right.len() + 1);
             }
 
             let key = ptr::read(self.keys().get_unchecked(right_offset - 1));
@@ -1305,22 +1310,18 @@ impl<K, V> Node<K, V> {
             ptr::write(self.keys_mut().get_unchecked_mut(old_len), key);
             ptr::write(self.vals_mut().get_unchecked_mut(old_len), val);
 
-            ptr::copy_nonoverlapping(
-                right.keys().as_ptr(),
-                self.keys_mut().as_mut_ptr().offset(old_len as isize + 1),
-                right.len()
-            );
-            ptr::copy_nonoverlapping(
-                right.vals().as_ptr(),
-                self.vals_mut().as_mut_ptr().offset(old_len as isize + 1),
-                right.len()
-            );
+            ptr::copy_nonoverlapping(right.keys().as_ptr(),
+                                     self.keys_mut().as_mut_ptr().offset(old_len as isize + 1),
+                                     right.len());
+            ptr::copy_nonoverlapping(right.vals().as_ptr(),
+                                     self.vals_mut().as_mut_ptr().offset(old_len as isize + 1),
+                                     right.len());
             if !self.is_leaf() {
-                ptr::copy_nonoverlapping(
-                    right.edges().as_ptr(),
-                    self.edges_mut().as_mut_ptr().offset(old_len as isize + 1),
-                    right.len() + 1
-                );
+                ptr::copy_nonoverlapping(right.edges().as_ptr(),
+                                         self.edges_mut()
+                                             .as_mut_ptr()
+                                             .offset(old_len as isize + 1),
+                                         right.len() + 1);
             }
 
             right.destroy();
@@ -1382,7 +1383,7 @@ struct MoveTraversalImpl<K, V> {
     // For deallocation when we are done iterating.
     ptr: Unique<u8>,
     capacity: usize,
-    is_leaf: bool
+    is_leaf: bool,
 }
 
 unsafe impl<K: Sync, V: Sync> Sync for MoveTraversalImpl<K, V> {}
@@ -1395,14 +1396,14 @@ impl<K, V> TraversalImpl for MoveTraversalImpl<K, V> {
     fn next_kv(&mut self) -> Option<(K, V)> {
         match (self.keys.next(), self.vals.next()) {
             (Some(k), Some(v)) => Some((k, v)),
-            _ => None
+            _ => None,
         }
     }
 
     fn next_kv_back(&mut self) -> Option<(K, V)> {
         match (self.keys.next_back(), self.vals.next_back()) {
             (Some(k), Some(v)) => Some((k, v)),
-            _ => None
+            _ => None,
         }
     }
 
@@ -1428,8 +1429,7 @@ impl<K, V> Drop for MoveTraversalImpl<K, V> {
         for _ in self.vals.by_ref() {}
         for _ in self.edges.by_ref() {}
 
-        let (alignment, size) =
-                calculate_allocation_generic::<K, V>(self.capacity, self.is_leaf);
+        let (alignment, size) = calculate_allocation_generic::<K, V>(self.capacity, self.is_leaf);
         unsafe { heap::deallocate(*self.ptr, size, alignment) };
     }
 }
@@ -1467,27 +1467,24 @@ pub type MoveTraversal<K, V> = AbsTraversal<MoveTraversalImpl<K, V>>;
 
 
 impl<K, V, E, Impl> Iterator for AbsTraversal<Impl>
-        where Impl: TraversalImpl<Item=(K, V), Edge=E> {
+    where Impl: TraversalImpl<Item = (K, V), Edge = E>
+{
     type Item = TraversalItem<K, V, E>;
 
     fn next(&mut self) -> Option<TraversalItem<K, V, E>> {
-        self.next_edge_item().map(Edge).or_else(||
-            self.next_kv_item().map(Elem)
-        )
+        self.next_edge_item().map(Edge).or_else(|| self.next_kv_item().map(Elem))
     }
 }
 
 impl<K, V, E, Impl> DoubleEndedIterator for AbsTraversal<Impl>
-        where Impl: TraversalImpl<Item=(K, V), Edge=E> {
+    where Impl: TraversalImpl<Item = (K, V), Edge = E>
+{
     fn next_back(&mut self) -> Option<TraversalItem<K, V, E>> {
-        self.next_edge_item_back().map(Edge).or_else(||
-            self.next_kv_item_back().map(Elem)
-        )
+        self.next_edge_item_back().map(Edge).or_else(|| self.next_kv_item_back().map(Elem))
     }
 }
 
-impl<K, V, E, Impl> AbsTraversal<Impl>
-        where Impl: TraversalImpl<Item=(K, V), Edge=E> {
+impl<K, V, E, Impl> AbsTraversal<Impl> where Impl: TraversalImpl<Item = (K, V), Edge = E> {
     /// Advances the iterator and returns the item if it's an edge. Returns None
     /// and does nothing if the first item is not an edge.
     pub fn next_edge_item(&mut self) -> Option<E> {
diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs
index 0c70a1544ef..6f3fadb7f0c 100644
--- a/src/libcollections/btree/set.rs
+++ b/src/libcollections/btree/set.rs
@@ -34,51 +34,51 @@ use Bound;
 /// normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
 #[derive(Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct BTreeSet<T>{
+pub struct BTreeSet<T> {
     map: BTreeMap<T, ()>,
 }
 
 /// An iterator over a BTreeSet's items.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct Iter<'a, T: 'a> {
-    iter: Keys<'a, T, ()>
+    iter: Keys<'a, T, ()>,
 }
 
 /// An owning iterator over a BTreeSet's items.
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct IntoIter<T> {
-    iter: Map<::btree_map::IntoIter<T, ()>, fn((T, ())) -> T>
+    iter: Map<::btree_map::IntoIter<T, ()>, fn((T, ())) -> T>,
 }
 
 /// An iterator over a sub-range of BTreeSet's items.
 pub struct Range<'a, T: 'a> {
-    iter: Map<::btree_map::Range<'a, T, ()>, fn((&'a T, &'a ())) -> &'a T>
+    iter: Map<::btree_map::Range<'a, T, ()>, fn((&'a T, &'a ())) -> &'a T>,
 }
 
 /// A lazy iterator producing elements in the set difference (in-order).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct Difference<'a, T:'a> {
+pub struct Difference<'a, T: 'a> {
     a: Peekable<Iter<'a, T>>,
     b: Peekable<Iter<'a, T>>,
 }
 
 /// A lazy iterator producing elements in the set symmetric difference (in-order).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct SymmetricDifference<'a, T:'a> {
+pub struct SymmetricDifference<'a, T: 'a> {
     a: Peekable<Iter<'a, T>>,
     b: Peekable<Iter<'a, T>>,
 }
 
 /// A lazy iterator producing elements in the set intersection (in-order).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct Intersection<'a, T:'a> {
+pub struct Intersection<'a, T: 'a> {
     a: Peekable<Iter<'a, T>>,
     b: Peekable<Iter<'a, T>>,
 }
 
 /// A lazy iterator producing elements in the set union (in-order).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub struct Union<'a, T:'a> {
+pub struct Union<'a, T: 'a> {
     a: Peekable<Iter<'a, T>>,
     b: Peekable<Iter<'a, T>>,
 }
@@ -161,12 +161,15 @@ impl<T: Ord> BTreeSet<T> {
     #[unstable(feature = "btree_range",
                reason = "matches collection reform specification, waiting for dust to settle",
                issue = "27787")]
-    pub fn range<'a, Min: ?Sized + Ord = T, Max: ?Sized + Ord = T>(&'a self, min: Bound<&Min>,
+    pub fn range<'a, Min: ?Sized + Ord = T, Max: ?Sized + Ord = T>(&'a self,
+                                                                   min: Bound<&Min>,
                                                                    max: Bound<&Max>)
-        -> Range<'a, T> where
-        T: Borrow<Min> + Borrow<Max>,
+                                                                   -> Range<'a, T>
+        where T: Borrow<Min> + Borrow<Max>
     {
-        fn first<A, B>((a, _): (A, B)) -> A { a }
+        fn first<A, B>((a, _): (A, B)) -> A {
+            a
+        }
         let first: fn((&'a T, &'a ())) -> &'a T = first; // coerce to fn pointer
 
         Range { iter: self.map.range(min, max).map(first) }
@@ -194,7 +197,10 @@ impl<T: Ord> BTreeSet<T> {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn difference<'a>(&'a self, other: &'a BTreeSet<T>) -> Difference<'a, T> {
-        Difference{a: self.iter().peekable(), b: other.iter().peekable()}
+        Difference {
+            a: self.iter().peekable(),
+            b: other.iter().peekable(),
+        }
     }
 
     /// Visits the values representing the symmetric difference, in ascending order.
@@ -216,9 +222,13 @@ impl<T: Ord> BTreeSet<T> {
     /// assert_eq!(sym_diff, [1, 3]);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn symmetric_difference<'a>(&'a self, other: &'a BTreeSet<T>)
-        -> SymmetricDifference<'a, T> {
-        SymmetricDifference{a: self.iter().peekable(), b: other.iter().peekable()}
+    pub fn symmetric_difference<'a>(&'a self,
+                                    other: &'a BTreeSet<T>)
+                                    -> SymmetricDifference<'a, T> {
+        SymmetricDifference {
+            a: self.iter().peekable(),
+            b: other.iter().peekable(),
+        }
     }
 
     /// Visits the values representing the intersection, in ascending order.
@@ -240,9 +250,11 @@ impl<T: Ord> BTreeSet<T> {
     /// assert_eq!(intersection, [2]);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn intersection<'a>(&'a self, other: &'a BTreeSet<T>)
-        -> Intersection<'a, T> {
-        Intersection{a: self.iter().peekable(), b: other.iter().peekable()}
+    pub fn intersection<'a>(&'a self, other: &'a BTreeSet<T>) -> Intersection<'a, T> {
+        Intersection {
+            a: self.iter().peekable(),
+            b: other.iter().peekable(),
+        }
     }
 
     /// Visits the values representing the union, in ascending order.
@@ -263,7 +275,10 @@ impl<T: Ord> BTreeSet<T> {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn union<'a>(&'a self, other: &'a BTreeSet<T>) -> Union<'a, T> {
-        Union{a: self.iter().peekable(), b: other.iter().peekable()}
+        Union {
+            a: self.iter().peekable(),
+            b: other.iter().peekable(),
+        }
     }
 
     /// Returns the number of elements in the set.
@@ -279,7 +294,9 @@ impl<T: Ord> BTreeSet<T> {
     /// assert_eq!(v.len(), 1);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn len(&self) -> usize { self.map.len() }
+    pub fn len(&self) -> usize {
+        self.map.len()
+    }
 
     /// Returns true if the set contains no elements.
     ///
@@ -294,7 +311,9 @@ impl<T: Ord> BTreeSet<T> {
     /// assert!(!v.is_empty());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn is_empty(&self) -> bool { self.len() == 0 }
+    pub fn is_empty(&self) -> bool {
+        self.len() == 0
+    }
 
     /// Clears the set, removing all values.
     ///
@@ -329,7 +348,10 @@ impl<T: Ord> BTreeSet<T> {
     /// assert_eq!(set.contains(&4), false);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool where T: Borrow<Q>, Q: Ord {
+    pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
+        where T: Borrow<Q>,
+              Q: Ord
+    {
         self.map.contains_key(value)
     }
 
@@ -339,7 +361,10 @@ impl<T: Ord> BTreeSet<T> {
     /// but the ordering on the borrowed form *must* match the
     /// ordering on the value type.
     #[unstable(feature = "set_recovery", issue = "28050")]
-    pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T> where T: Borrow<Q>, Q: Ord {
+    pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
+        where T: Borrow<Q>,
+              Q: Ord
+    {
         Recover::get(&self.map, value)
     }
 
@@ -482,7 +507,10 @@ impl<T: Ord> BTreeSet<T> {
     /// assert_eq!(set.remove(&2), false);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool where T: Borrow<Q>, Q: Ord {
+    pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
+        where T: Borrow<Q>,
+              Q: Ord
+    {
         self.map.remove(value).is_some()
     }
 
@@ -492,14 +520,17 @@ impl<T: Ord> BTreeSet<T> {
     /// but the ordering on the borrowed form *must* match the
     /// ordering on the value type.
     #[unstable(feature = "set_recovery", issue = "28050")]
-    pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T> where T: Borrow<Q>, Q: Ord {
+    pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
+        where T: Borrow<Q>,
+              Q: Ord
+    {
         Recover::take(&mut self.map, value)
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Ord> FromIterator<T> for BTreeSet<T> {
-    fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> BTreeSet<T> {
+    fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> BTreeSet<T> {
         let mut set = BTreeSet::new();
         set.extend(iter);
         set
@@ -524,7 +555,9 @@ impl<T> IntoIterator for BTreeSet<T> {
     /// assert_eq!(v, [1, 2, 3, 4]);
     /// ```
     fn into_iter(self) -> IntoIter<T> {
-        fn first<A, B>((a, _): (A, B)) -> A { a }
+        fn first<A, B>((a, _): (A, B)) -> A {
+            a
+        }
         let first: fn((T, ())) -> T = first; // coerce to fn pointer
 
         IntoIter { iter: self.map.into_iter().map(first) }
@@ -544,7 +577,7 @@ impl<'a, T> IntoIterator for &'a BTreeSet<T> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Ord> Extend<T> for BTreeSet<T> {
     #[inline]
-    fn extend<Iter: IntoIterator<Item=T>>(&mut self, iter: Iter) {
+    fn extend<Iter: IntoIterator<Item = T>>(&mut self, iter: Iter) {
         for elem in iter {
             self.insert(elem);
         }
@@ -553,7 +586,7 @@ impl<T: Ord> Extend<T> for BTreeSet<T> {
 
 #[stable(feature = "extend_ref", since = "1.2.0")]
 impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BTreeSet<T> {
-    fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
+    fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
         self.extend(iter.into_iter().cloned());
     }
 }
@@ -665,18 +698,26 @@ impl<T: Debug> Debug for BTreeSet<T> {
 }
 
 impl<'a, T> Clone for Iter<'a, T> {
-    fn clone(&self) -> Iter<'a, T> { Iter { iter: self.iter.clone() } }
+    fn clone(&self) -> Iter<'a, T> {
+        Iter { iter: self.iter.clone() }
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T> Iterator for Iter<'a, T> {
     type Item = &'a T;
 
-    fn next(&mut self) -> Option<&'a T> { self.iter.next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
+    fn next(&mut self) -> Option<&'a T> {
+        self.iter.next()
+    }
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.iter.size_hint()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
-    fn next_back(&mut self) -> Option<&'a T> { self.iter.next_back() }
+    fn next_back(&mut self) -> Option<&'a T> {
+        self.iter.next_back()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T> ExactSizeIterator for Iter<'a, T> {}
@@ -686,42 +727,56 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {}
 impl<T> Iterator for IntoIter<T> {
     type Item = T;
 
-    fn next(&mut self) -> Option<T> { self.iter.next() }
-    fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
+    fn next(&mut self) -> Option<T> {
+        self.iter.next()
+    }
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        self.iter.size_hint()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> DoubleEndedIterator for IntoIter<T> {
-    fn next_back(&mut self) -> Option<T> { self.iter.next_back() }
+    fn next_back(&mut self) -> Option<T> {
+        self.iter.next_back()
+    }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ExactSizeIterator for IntoIter<T> {}
 
 
 impl<'a, T> Clone for Range<'a, T> {
-    fn clone(&self) -> Range<'a, T> { Range { iter: self.iter.clone() } }
+    fn clone(&self) -> Range<'a, T> {
+        Range { iter: self.iter.clone() }
+    }
 }
 impl<'a, T> Iterator for Range<'a, T> {
     type Item = &'a T;
 
-    fn next(&mut self) -> Option<&'a T> { self.iter.next() }
+    fn next(&mut self) -> Option<&'a T> {
+        self.iter.next()
+    }
 }
 impl<'a, T> DoubleEndedIterator for Range<'a, T> {
-    fn next_back(&mut self) -> Option<&'a T> { self.iter.next_back() }
+    fn next_back(&mut self) -> Option<&'a T> {
+        self.iter.next_back()
+    }
 }
 
 /// Compare `x` and `y`, but return `short` if x is None and `long` if y is None
-fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>,
-                        short: Ordering, long: Ordering) -> Ordering {
+fn cmp_opt<T: Ord>(x: Option<&T>, y: Option<&T>, short: Ordering, long: Ordering) -> Ordering {
     match (x, y) {
-        (None    , _       ) => short,
-        (_       , None    ) => long,
+        (None, _) => short,
+        (_, None) => long,
         (Some(x1), Some(y1)) => x1.cmp(y1),
     }
 }
 
 impl<'a, T> Clone for Difference<'a, T> {
     fn clone(&self) -> Difference<'a, T> {
-        Difference { a: self.a.clone(), b: self.b.clone() }
+        Difference {
+            a: self.a.clone(),
+            b: self.b.clone(),
+        }
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -731,9 +786,14 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> {
     fn next(&mut self) -> Option<&'a T> {
         loop {
             match cmp_opt(self.a.peek(), self.b.peek(), Less, Less) {
-                Less    => return self.a.next(),
-                Equal   => { self.a.next(); self.b.next(); }
-                Greater => { self.b.next(); }
+                Less => return self.a.next(),
+                Equal => {
+                    self.a.next();
+                    self.b.next();
+                }
+                Greater => {
+                    self.b.next();
+                }
             }
         }
     }
@@ -741,7 +801,10 @@ impl<'a, T: Ord> Iterator for Difference<'a, T> {
 
 impl<'a, T> Clone for SymmetricDifference<'a, T> {
     fn clone(&self) -> SymmetricDifference<'a, T> {
-        SymmetricDifference { a: self.a.clone(), b: self.b.clone() }
+        SymmetricDifference {
+            a: self.a.clone(),
+            b: self.b.clone(),
+        }
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -751,8 +814,11 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {
     fn next(&mut self) -> Option<&'a T> {
         loop {
             match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {
-                Less    => return self.a.next(),
-                Equal   => { self.a.next(); self.b.next(); }
+                Less => return self.a.next(),
+                Equal => {
+                    self.a.next();
+                    self.b.next();
+                }
                 Greater => return self.b.next(),
             }
         }
@@ -761,7 +827,10 @@ impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {
 
 impl<'a, T> Clone for Intersection<'a, T> {
     fn clone(&self) -> Intersection<'a, T> {
-        Intersection { a: self.a.clone(), b: self.b.clone() }
+        Intersection {
+            a: self.a.clone(),
+            b: self.b.clone(),
+        }
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -771,15 +840,22 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> {
     fn next(&mut self) -> Option<&'a T> {
         loop {
             let o_cmp = match (self.a.peek(), self.b.peek()) {
-                (None    , _       ) => None,
-                (_       , None    ) => None,
+                (None, _) => None,
+                (_, None) => None,
                 (Some(a1), Some(b1)) => Some(a1.cmp(b1)),
             };
             match o_cmp {
-                None          => return None,
-                Some(Less)    => { self.a.next(); }
-                Some(Equal)   => { self.b.next(); return self.a.next() }
-                Some(Greater) => { self.b.next(); }
+                None => return None,
+                Some(Less) => {
+                    self.a.next();
+                }
+                Some(Equal) => {
+                    self.b.next();
+                    return self.a.next();
+                }
+                Some(Greater) => {
+                    self.b.next();
+                }
             }
         }
     }
@@ -787,7 +863,10 @@ impl<'a, T: Ord> Iterator for Intersection<'a, T> {
 
 impl<'a, T> Clone for Union<'a, T> {
     fn clone(&self) -> Union<'a, T> {
-        Union { a: self.a.clone(), b: self.b.clone() }
+        Union {
+            a: self.a.clone(),
+            b: self.b.clone(),
+        }
     }
 }
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -797,8 +876,11 @@ impl<'a, T: Ord> Iterator for Union<'a, T> {
     fn next(&mut self) -> Option<&'a T> {
         loop {
             match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {
-                Less    => return self.a.next(),
-                Equal   => { self.b.next(); return self.a.next() }
+                Less => return self.a.next(),
+                Equal => {
+                    self.b.next();
+                    return self.a.next();
+                }
                 Greater => return self.b.next(),
             }
         }