inner: Map<(&'a K, &'a V), &'a V, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
}
-#[stable]
/// A view into a single entry in a map, which may either be vacant or occupied.
+#[unstable = "precise API still under development"]
pub enum Entry<'a, K:'a, V:'a> {
/// A vacant Entry
Vacant(VacantEntry<'a, K, V>),
Occupied(OccupiedEntry<'a, K, V>),
}
-#[stable]
/// A vacant Entry.
+#[unstable = "precise API still under development"]
pub struct VacantEntry<'a, K:'a, V:'a> {
key: K,
stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
}
-#[stable]
/// An occupied Entry.
+#[unstable = "precise API still under development"]
pub struct OccupiedEntry<'a, K:'a, V:'a> {
stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>,
}
}
impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
- #[stable]
/// Sets the value of the entry with the VacantEntry's key,
/// and returns a mutable reference to it.
+ #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
pub fn insert(self, value: V) -> &'a mut V {
self.stack.insert(self.key, value)
}
}
impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
- #[stable]
/// Gets a reference to the value in the entry.
+ #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
pub fn get(&self) -> &V {
self.stack.peek()
}
- #[stable]
/// Gets a mutable reference to the value in the entry.
+ #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
pub fn get_mut(&mut self) -> &mut V {
self.stack.peek_mut()
}
- #[stable]
/// Converts the entry into a mutable reference to its value.
+ #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
pub fn into_mut(self) -> &'a mut V {
self.stack.into_top()
}
- #[stable]
/// Sets the value of the entry with the OccupiedEntry's key,
/// and returns the entry's old value.
+ #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
pub fn insert(&mut self, mut value: V) -> V {
mem::swap(self.stack.peek_mut(), &mut value);
value
}
- #[stable]
/// Takes the value of the entry out of the map, and returns it.
+ #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
pub fn remove(self) -> V {
self.stack.remove()
}
/// assert_eq!(count["a"], 3u);
/// ```
/// The key must have the same ordering before or after `.to_owned()` is called.
- #[stable]
+ #[unstable = "precise API still under development"]
pub fn entry<'a>(&'a mut self, mut key: K) -> Entry<'a, K, V> {
// same basic logic of `swap` and `pop`, blended together
let mut stack = stack::PartialSearchStack::new(self);
}
}
- #[stable]
/// Gets the given key's corresponding entry in the map for in-place manipulation.
+ #[unstable = "precise API still being fleshed out"]
pub fn entry<'a>(&'a mut self, key: K) -> Entry<'a, K, V>
{
// Gotta resize now.
>
}
-#[stable]
/// A view into a single occupied location in a HashMap
+#[unstable = "precise API still being fleshed out"]
pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
elem: FullBucket<K, V, &'a mut RawTable<K, V>>,
}
-#[stable]
/// A view into a single empty location in a HashMap
+#[unstable = "precise API still being fleshed out"]
pub struct VacantEntry<'a, K: 'a, V: 'a> {
hash: SafeHash,
key: K,
elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
}
-#[stable]
/// A view into a single location in a map, which may be vacant or occupied
+#[unstable = "precise API still being fleshed out"]
pub enum Entry<'a, K: 'a, V: 'a> {
/// An occupied Entry
Occupied(OccupiedEntry<'a, K, V>),
}
}
+#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
impl<'a, K, V> Entry<'a, K, V> {
- #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
/// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
match self {
}
}
+#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
impl<'a, K, V> OccupiedEntry<'a, K, V> {
- #[stable]
/// Gets a reference to the value in the entry
pub fn get(&self) -> &V {
self.elem.read().1
}
- #[stable]
/// Gets a mutable reference to the value in the entry
pub fn get_mut(&mut self) -> &mut V {
self.elem.read_mut().1
}
- #[stable]
/// Converts the OccupiedEntry into a mutable reference to the value in the entry
/// with a lifetime bound to the map itself
pub fn into_mut(self) -> &'a mut V {
self.elem.into_mut_refs().1
}
- #[stable]
/// Sets the value of the entry, and returns the entry's old value
pub fn insert(&mut self, mut value: V) -> V {
let old_value = self.get_mut();
value
}
- #[stable]
/// Takes the value out of the entry, and returns it
pub fn remove(self) -> V {
pop_internal(self.elem).1
}
}
+#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> {
- #[stable]
/// Sets the value of the entry with the VacantEntry's key,
/// and returns a mutable reference to it
pub fn insert(self, value: V) -> &'a mut V {