pub struct HashMapChild<'a, K, T>(/* private fields */);
Implementations§
Source§impl<'a, K, T> HashMapChild<'a, K, T>
impl<'a, K, T> HashMapChild<'a, K, T>
Sourcepub fn contains_key<Q>(&self, k: &Q) -> bool
pub fn contains_key<Q>(&self, k: &Q) -> bool
Returns true
if the map contains a value for the specified key.
let mut map = HashMapOwner::new();
let mut map = map.child();
let value = map.insert("10".to_string(), Box::new(10));
assert!(map.contains_key("10"));
Sourcepub fn try_insert(&mut self, key: K, v: T) -> Option<&'a T::Ref>
pub fn try_insert(&mut self, key: K, v: T) -> Option<&'a T::Ref>
Tries to insert key and value if key already exists returns None
Else returns a reference to the inserted value without using the current lifetime
let mut map = HashMapOwner::new();
let mut map = map.child();
let v1 = map.try_insert("10", Box::new(10)).unwrap();
let v2 = map.try_insert("20", Box::new(20)).unwrap();
assert_eq!(*v1, 10);
assert_eq!(*v2, 20);
Sourcepub fn insert(&mut self, key: K, v: T) -> &'a T::Ref
pub fn insert(&mut self, key: K, v: T) -> &'a T::Ref
Insert key and value to the owner
Else returns a reference to the inserted value without using the current lifetime
§Panics
Panics if key already exists
let mut map = HashMapOwner::new();
let mut map = map.child();
let v1 = map.insert("10", Box::new(10));
let v2 = map.insert("20", Box::new(20));
assert_eq!(*v1, 10);
assert_eq!(*v2, 20);
Trait Implementations§
Auto Trait Implementations§
impl<'a, K, T> Freeze for HashMapChild<'a, K, T>
impl<'a, K, T> RefUnwindSafe for HashMapChild<'a, K, T>where
K: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, K, T> Send for HashMapChild<'a, K, T>
impl<'a, K, T> Sync for HashMapChild<'a, K, T>
impl<'a, K, T> Unpin for HashMapChild<'a, K, T>
impl<'a, K, T> !UnwindSafe for HashMapChild<'a, K, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more