use self::Entry::*;
-use core::prelude::*;
+#[cfg(stage0)]
+use core::prelude::v1::*;
use core::cmp::Ordering;
use core::fmt::Debug;
/// to nodes. By using this module much better safety guarantees can be made, and more search
/// boilerplate gets cut out.
mod stack {
- use core::prelude::*;
+ #[cfg(stage0)]
+ use core::prelude::v1::*;
use core::marker;
use core::mem;
use core::ops::{Deref, DerefMut};
/// tied to the original tree.
pub fn into_top(mut self) -> &'a mut V {
unsafe {
- mem::copy_mut_lifetime(
- self.map,
- self.top.from_raw_mut().val_mut()
- )
+ &mut *(self.top.from_raw_mut().val_mut() as *mut V)
}
}
}
}
impl<'a, K: Ord, V> Entry<'a, K, V> {
- #[unstable(feature = "std_misc",
+ #[unstable(feature = "entry",
reason = "will soon be replaced by or_insert")]
#[deprecated(since = "1.0",
reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")]
/// # Examples
///
/// ```
- /// # #![feature(collections)]
+ /// #![feature(btree_range, collections_bound)]
+ ///
/// use std::collections::BTreeMap;
/// use std::collections::Bound::{Included, Unbounded};
///
/// }
/// assert_eq!(Some((&5, &"b")), map.range(Included(&4), Unbounded).next());
/// ```
- #[unstable(feature = "collections",
+ #[unstable(feature = "btree_range",
reason = "matches collection reform specification, waiting for dust to settle")]
- pub fn range<'a>(&'a self, min: Bound<&K>, max: Bound<&K>) -> Range<'a, K, V> {
+ 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_impl!(&self.root, min, max, as_slices_internal, iter, Range, edges, [])
}
/// # Examples
///
/// ```
- /// # #![feature(collections)]
+ /// #![feature(btree_range, collections_bound)]
+ ///
/// use std::collections::BTreeMap;
/// use std::collections::Bound::{Included, Excluded};
///
/// let mut map: BTreeMap<&str, i32> = ["Alice", "Bob", "Carol", "Cheryl"].iter()
/// .map(|&s| (s, 0))
/// .collect();
- /// for (_, balance) in map.range_mut(Included(&"B"), Excluded(&"Cheryl")) {
+ /// for (_, balance) in map.range_mut(Included("B"), Excluded("Cheryl")) {
/// *balance += 100;
/// }
/// for (name, balance) in &map {
/// println!("{} => {}", name, balance);
/// }
/// ```
- #[unstable(feature = "collections",
+ #[unstable(feature = "btree_range",
reason = "matches collection reform specification, waiting for dust to settle")]
- pub fn range_mut<'a>(&'a mut self, min: Bound<&K>, max: Bound<&K>) -> RangeMut<'a, K, V> {
+ 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>,
+ {
range_impl!(&mut self.root, min, max, as_slices_internal_mut, iter_mut, RangeMut,
edges_mut, [mut])
}