|
|
|
@ -11,7 +11,6 @@ use crate::{ |
|
|
|
|
__runtime::InnerMapMut, |
|
|
|
|
}; |
|
|
|
|
use std::marker::PhantomData; |
|
|
|
|
use std::ops::Deref; |
|
|
|
|
|
|
|
|
|
#[repr(transparent)] |
|
|
|
|
pub struct MapView<'msg, K: ?Sized, V: ?Sized> { |
|
|
|
@ -27,15 +26,6 @@ impl<'msg, K: ?Sized, V: ?Sized> Clone for MapView<'msg, K, V> { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl<'msg, K: ?Sized, V: ?Sized> Deref for MapMut<'msg, K, V> { |
|
|
|
|
type Target = MapView<'msg, K, V>; |
|
|
|
|
fn deref(&self) -> &Self::Target { |
|
|
|
|
// SAFETY:
|
|
|
|
|
// - `MapView<'msg, K, V>` is `#[repr(transparent)]` over `RawMap`.
|
|
|
|
|
unsafe { &*(&self.inner.raw as *const RawMap as *const MapView<'msg, K, V>) } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
unsafe impl<'msg, K: ?Sized, V: ?Sized> Sync for MapView<'msg, K, V> {} |
|
|
|
|
unsafe impl<'msg, K: ?Sized, V: ?Sized> Send for MapView<'msg, K, V> {} |
|
|
|
|
|
|
|
|
@ -233,6 +223,14 @@ where |
|
|
|
|
Self { inner, _phantom_key: PhantomData, _phantom_value: PhantomData } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn len(self) -> usize { |
|
|
|
|
self.as_view().len() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn is_empty(self) -> bool { |
|
|
|
|
self.len() == 0 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn insert<'a, 'b>( |
|
|
|
|
&mut self, |
|
|
|
|
key: impl Into<View<'a, K>>, |
|
|
|
|