]> git.lizzy.rs Git - rust.git/commitdiff
Fix more import_shadowing fallout in collections.
authorEduard Burtescu <edy.burt@gmail.com>
Thu, 18 Dec 2014 04:15:39 +0000 (06:15 +0200)
committerEduard Burtescu <edy.burt@gmail.com>
Sat, 20 Dec 2014 05:49:37 +0000 (07:49 +0200)
src/libcollections/btree/map.rs
src/libcollections/btree/node.rs
src/libcollections/str.rs
src/libstd/c_str.rs

index c7cbb5a1c299e25b59c485b08b3cbebf6e3d80f9..dc69c5993c1af21af806e7556ab1aa35581c324e 100644 (file)
@@ -131,12 +131,12 @@ pub enum Entry<'a, K:'a, V:'a> {
 /// A vacant Entry.
 pub struct VacantEntry<'a, K:'a, V:'a> {
     key: K,
-    stack: stack::SearchStack<'a, K, V, node::Edge, node::Leaf>,
+    stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
 }
 
 /// An occupied Entry.
 pub struct OccupiedEntry<'a, K:'a, V:'a> {
-    stack: stack::SearchStack<'a, K, V, node::KV, node::LeafOrInternal>,
+    stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>,
 }
 
 impl<K: Ord, V> BTreeMap<K, V> {
@@ -496,7 +496,8 @@ mod stack {
     use core::kinds::marker;
     use core::mem;
     use super::BTreeMap;
-    use super::super::node::{mod, Node, Fit, Split, KV, Edge, Internal, Leaf, LeafOrInternal};
+    use super::super::node::{mod, Node, Fit, Split, Internal, Leaf};
+    use super::super::node::handle;
     use vec::Vec;
 
     /// A generic mutable reference, identical to `&mut` except for the fact that its lifetime
@@ -520,7 +521,7 @@ fn deref_mut(&mut self) -> &mut T {
         }
     }
 
-    type StackItem<K, V> = node::Handle<*mut Node<K, V>, Edge, Internal>;
+    type StackItem<K, V> = node::Handle<*mut Node<K, V>, handle::Edge, handle::Internal>;
     type Stack<K, V> = Vec<StackItem<K, V>>;
 
     /// A `PartialSearchStack` handles the construction of a search stack.
@@ -595,7 +596,9 @@ impl<'id, 'a, K, V> Pusher<'id, 'a, K, V> {
         /// 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>>, Edge, 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 {
@@ -617,7 +620,7 @@ pub fn seal<Type, NodeType>
         }
     }
 
-    impl<'a, K, V, NodeType> SearchStack<'a, K, V, KV, NodeType> {
+    impl<'a, K, V, NodeType> SearchStack<'a, K, V, handle::KV, NodeType> {
         /// Gets a reference to the value the stack points to.
         pub fn peek(&self) -> &V {
             unsafe { self.top.from_raw().into_kv().1 }
@@ -640,7 +643,7 @@ pub fn into_top(mut self) -> &'a mut V {
         }
     }
 
-    impl<'a, K, V> SearchStack<'a, K, V, KV, Leaf> {
+    impl<'a, K, V> SearchStack<'a, K, V, handle::KV, handle::Leaf> {
         /// Removes the key and value in the top element of the stack, then handles underflows as
         /// described in BTree's pop function.
         fn remove_leaf(mut self) -> V {
@@ -686,7 +689,7 @@ fn remove_leaf(mut self) -> V {
         }
     }
 
-    impl<'a, K, V> SearchStack<'a, K, V, KV, LeafOrInternal> {
+    impl<'a, K, V> SearchStack<'a, K, V, handle::KV, handle::LeafOrInternal> {
         /// Removes the key and value in the top element of the stack, then handles underflows as
         /// described in BTree's pop function.
         pub fn remove(self) -> V {
@@ -703,7 +706,7 @@ pub fn remove(self) -> V {
         /// leaves the tree in an inconsistent state that must be repaired by the caller by
         /// removing the entry in question. Specifically the key-value pair and its successor will
         /// become swapped.
-        fn into_leaf(mut self) -> SearchStack<'a, K, V, KV, Leaf> {
+        fn into_leaf(mut self) -> SearchStack<'a, K, V, handle::KV, handle::Leaf> {
             unsafe {
                 let mut top_raw = self.top;
                 let mut top = top_raw.from_raw_mut();
@@ -757,7 +760,7 @@ fn into_leaf(mut self) -> SearchStack<'a, K, V, KV, Leaf> {
         }
     }
 
-    impl<'a, K, V> SearchStack<'a, K, V, Edge, Leaf> {
+    impl<'a, K, V> SearchStack<'a, K, V, handle::Edge, handle::Leaf> {
         /// Inserts the key and value into the top element in the stack, and if that node has to
         /// split recursively inserts the split contents into the next element stack until
         /// splits stop.
index 9698b06c7fa0f266c7bd52f89e11d0c541959470..1666f42d82bb5384fb0f88abfab936c594d9064f 100644 (file)
@@ -34,9 +34,9 @@ pub enum InsertionResult<K, V> {
 /// Represents the result of a search for a key in a single node
 pub enum SearchResult<NodeRef> {
     /// The element was found at the given index
-    Found(Handle<NodeRef, KV, LeafOrInternal>),
+    Found(Handle<NodeRef, handle::KV, handle::LeafOrInternal>),
     /// The element wasn't found, but if it's anywhere, it must be beyond this edge
-    GoDown(Handle<NodeRef, Edge, LeafOrInternal>),
+    GoDown(Handle<NodeRef, handle::Edge, handle::LeafOrInternal>),
 }
 
 /// A B-Tree Node. We keep keys/edges/values separate to optimize searching for keys.
@@ -494,12 +494,16 @@ pub struct Handle<NodeRef, Type, NodeType> {
     index: uint
 }
 
-pub enum KV {}
-pub enum Edge {}
+pub mod handle {
+    // Handle types.
+    pub enum KV {}
+    pub enum Edge {}
 
-pub enum LeafOrInternal {}
-pub enum Leaf {}
-pub enum Internal {}
+    // Handle node types.
+    pub enum LeafOrInternal {}
+    pub enum Leaf {}
+    pub enum Internal {}
+}
 
 impl<K: Ord, V> Node<K, V> {
     /// Searches for the given key in the node. If it finds an exact match,
@@ -625,7 +629,7 @@ pub unsafe fn from_raw_mut<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, Type,
     }
 }
 
-impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, Edge, Internal> {
+impl<'a, K: 'a, V: 'a> Handle<&'a Node<K, V>, handle::Edge, handle::Internal> {
     /// Turns the handle into a reference to the edge it points at. This is necessary because the
     /// 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.
@@ -636,7 +640,7 @@ pub fn into_edge(self) -> &'a Node<K, V> {
     }
 }
 
-impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, Edge, Internal> {
+impl<'a, K: 'a, V: 'a> Handle<&'a mut Node<K, V>, handle::Edge, handle::Internal> {
     /// Turns the handle into a mutable reference to the edge it points at. This is necessary
     /// 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.
@@ -647,7 +651,7 @@ pub fn into_edge_mut(self) -> &'a mut Node<K, V> {
     }
 }
 
-impl<K, V, NodeRef: Deref<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
+impl<K, V, NodeRef: Deref<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, analagous to edge_mut.
     //
@@ -657,11 +661,11 @@ impl<K, V, NodeRef: Deref<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
 }
 
 pub enum ForceResult<NodeRef, Type> {
-    Leaf(Handle<NodeRef, Type, Leaf>),
-    Internal(Handle<NodeRef, Type, Internal>)
+    Leaf(Handle<NodeRef, Type, handle::Leaf>),
+    Internal(Handle<NodeRef, Type, handle::Internal>)
 }
 
-impl<K, V, NodeRef: Deref<Node<K, V>>, Type> Handle<NodeRef, Type, LeafOrInternal> {
+impl<K, V, NodeRef: Deref<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> {
@@ -679,7 +683,7 @@ pub fn force(self) -> ForceResult<NodeRef, Type> {
     }
 }
 
-impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Leaf> {
+impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Leaf> {
     /// 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.
     ///
@@ -711,7 +715,7 @@ pub fn insert_as_leaf(mut self, key: K, value: V) ->
     }
 }
 
-impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, Edge, Internal> {
+impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::Edge, handle::Internal> {
     /// 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> {
@@ -794,11 +798,11 @@ unsafe fn handle_underflow_to_right(&mut self) {
     }
 }
 
-impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, Edge, NodeType> {
+impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::Edge, NodeType> {
     /// 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
     /// pair to its left.
-    unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, KV, NodeType> {
+    unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
         Handle {
             node: &mut *self.node,
             index: self.index - 1
@@ -808,7 +812,7 @@ unsafe fn left_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, KV, NodeType>
     /// Gets the handle pointing to the key/value pair just to the right of the pointed-to edge.
     /// This is unsafe because the handle might point to the last edge in the node, which has no
     /// pair to its right.
-    unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, KV, NodeType> {
+    unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
         Handle {
             node: &mut *self.node,
             index: self.index
@@ -816,7 +820,7 @@ unsafe fn right_kv<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, KV, NodeType>
     }
 }
 
-impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, KV, NodeType> {
+impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a Node<K, V>, handle::KV, NodeType> {
     /// Turns the handle into references to the key and value it points at. This is necessary
     /// because the returned pointers have larger lifetimes than what would be returned by `key`
     /// or `val`.
@@ -831,7 +835,7 @@ pub fn into_kv(self) -> (&'a K, &'a V) {
     }
 }
 
-impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, KV, NodeType> {
+impl<'a, K: 'a, V: 'a, NodeType> Handle<&'a mut Node<K, V>, handle::KV, NodeType> {
     /// Turns the handle into mutable references to the key and value it points at. This is
     /// necessary because the returned pointers have larger lifetimes than what would be returned
     /// by `key_mut` or `val_mut`.
@@ -848,7 +852,7 @@ pub fn into_kv_mut(self) -> (&'a mut K, &'a mut V) {
     /// Convert this handle into one pointing at the edge immediately to the left of the key/value
     /// pair pointed-to by this handle. This is useful because it returns a reference with larger
     /// lifetime than `left_edge`.
-    pub fn into_left_edge(self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
+    pub fn into_left_edge(self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
         Handle {
             node: &mut *self.node,
             index: self.index
@@ -856,7 +860,8 @@ pub fn into_left_edge(self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
     }
 }
 
-impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef, KV, NodeType> {
+impl<'a, K: 'a, V: 'a, NodeRef: Deref<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
@@ -874,7 +879,8 @@ impl<'a, K: 'a, V: 'a, NodeRef: Deref<Node<K, V>> + 'a, NodeType> Handle<NodeRef
     // }
 }
 
-impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<NodeRef, KV, NodeType> {
+impl<'a, K: 'a, V: 'a, NodeRef: DerefMut<Node<K, V>> + 'a, NodeType> Handle<NodeRef, handle::KV,
+                                                                            NodeType> {
     /// 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
     /// handle.
@@ -890,10 +896,10 @@ pub fn val_mut(&'a mut self) -> &'a mut V {
     }
 }
 
-impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, KV, NodeType> {
+impl<K, V, NodeRef: DerefMut<Node<K, V>>, NodeType> Handle<NodeRef, handle::KV, NodeType> {
     /// Gets the handle pointing to the edge immediately to the left of the key/value pair pointed
     /// to by this handle.
-    pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
+    pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
         Handle {
             node: &mut *self.node,
             index: self.index
@@ -902,7 +908,7 @@ pub fn left_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, Edge, NodeType>
 
     /// Gets the handle pointing to the edge immediately to the right of the key/value pair pointed
     /// to by this handle.
-    pub fn right_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, Edge, NodeType> {
+    pub fn right_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, handle::Edge, NodeType> {
         Handle {
             node: &mut *self.node,
             index: self.index + 1
@@ -910,7 +916,7 @@ pub fn right_edge<'a>(&'a mut self) -> Handle<&'a mut Node<K, V>, Edge, NodeType
     }
 }
 
-impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, KV, Leaf> {
+impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Leaf> {
     /// Removes the key/value pair at the handle's location.
     ///
     /// # Panics (in debug build)
@@ -921,7 +927,7 @@ pub fn remove_as_leaf(mut self) -> (K, V) {
     }
 }
 
-impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, KV, Internal> {
+impl<K, V, NodeRef: DerefMut<Node<K, V>>> Handle<NodeRef, handle::KV, handle::Internal> {
     /// Steal! Stealing is roughly analogous to a binary tree rotation.
     /// In this case, we're "rotating" right.
     unsafe fn steal_rightward(&mut self) {
@@ -1004,7 +1010,8 @@ 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: uint) -> Handle<&mut Node<K, V>, KV, LeafOrInternal> {
+    pub fn kv_handle(&mut self, index: uint) -> 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 {
index 9ac5f04efe5f28759e9e1a905f56dfb30ecaa823..dc8313386b9988bde3a2e5f241d27edf8b7b8dcd 100644 (file)
 
 #![doc(primitive = "str")]
 
-use core::prelude::*;
-
 pub use self::MaybeOwned::*;
 use self::RecompositionState::*;
 use self::DecompositionType::*;
 
 use core::borrow::{BorrowFrom, Cow, ToOwned};
+use core::clone::Clone;
 use core::default::Default;
 use core::fmt;
 use core::hash;
-use core::cmp;
-use core::iter::AdditiveIterator;
+use core::char::Char;
+use core::cmp::{mod, Eq, Equiv, Ord, Ordering, PartialEq, PartialOrd};
+use core::iter::{range, AdditiveIterator, Iterator, IteratorExt};
+use core::kinds::Sized;
+use core::option::Option::{mod, Some, None};
+use core::slice::{AsSlice, SliceExt};
 
 use ring_buf::RingBuf;
 use string::String;
index 8fe3642e702d44ce6d3f1a9e1cd9ea2db9d69f9b..f1c8e8950a22eed6915218d39004924fa008dcd6 100644 (file)
 //! }
 //! ```
 
-use string::String;
-use hash;
+use core::prelude::*;
+use libc;
+
 use fmt;
+use hash;
 use kinds::marker;
 use mem;
-use core::prelude::*;
-
 use ptr;
-use raw::Slice;
-use slice;
+use slice::{mod, ImmutableIntSlice};
 use str;
-use libc;
+use string::String;
+
 
 /// The representation of a C String.
 ///
@@ -210,7 +210,7 @@ pub fn owns_buffer(&self) -> bool {
     #[inline]
     pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
         unsafe {
-            mem::transmute(Slice { data: self.buf, len: self.len() + 1 })
+            slice::from_raw_buf(&self.buf, self.len() + 1).as_unsigned()
         }
     }
 
@@ -219,7 +219,7 @@ pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
     #[inline]
     pub fn as_bytes_no_nul<'a>(&'a self) -> &'a [u8] {
         unsafe {
-            mem::transmute(Slice { data: self.buf, len: self.len() })
+            slice::from_raw_buf(&self.buf, self.len()).as_unsigned()
         }
     }