pub struct Registry<K: Ord + Clone, T> { /* private fields */ }Expand description
Items by id, each owned.
Implementations§
Source§impl<K: Ord + Clone, T> Registry<K, T>
impl<K: Ord + Clone, T> Registry<K, T>
pub fn new() -> Self
Sourcepub fn insert(
&mut self,
owner: &OwnerId,
id: K,
item: T,
) -> Result<(), Taken<K>>
pub fn insert( &mut self, owner: &OwnerId, id: K, item: T, ) -> Result<(), Taken<K>>
Registers an item; refused when the id is taken.
pub fn get(&self, id: &K) -> Option<&T>
pub fn get_mut(&mut self, id: &K) -> Option<&mut T>
pub fn slot(&self, id: &K) -> Option<&Slot<T>>
pub fn owner(&self, id: &K) -> Option<&OwnerId>
pub fn contains(&self, id: &K) -> bool
pub fn remove(&mut self, id: &K) -> Option<Slot<T>>
Sourcepub fn remove_owner(&mut self, owner: &OwnerId) -> Vec<(K, T)>
pub fn remove_owner(&mut self, owner: &OwnerId) -> Vec<(K, T)>
Removes everything an owner registered; returns it, by id.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<K, T> Freeze for Registry<K, T>
impl<K, T> RefUnwindSafe for Registry<K, T>where
K: RefUnwindSafe,
T: RefUnwindSafe,
impl<K, T> Send for Registry<K, T>
impl<K, T> Sync for Registry<K, T>
impl<K, T> Unpin for Registry<K, T>
impl<K, T> UnsafeUnpin for Registry<K, T>
impl<K, T> UnwindSafe for Registry<K, T>where
K: RefUnwindSafe,
T: RefUnwindSafe,
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