Remove Deref from MapMut

PiperOrigin-RevId: 599329208
pull/15476/head
Alyssa Haroldsen 1 year ago committed by Copybara-Service
parent b6ea6f9192
commit c1bb1981a4
  1. 18
      rust/map.rs

@ -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>>,

Loading…
Cancel
Save