pub struct PortSlab<T> { /* private fields */ }
Expand description
A data structure that is keyed on Port
, guarantees O(1) lookup
and takes into account salted port identifiers.
Implementations§
Source§impl<T> PortSlab<T>
impl<T> PortSlab<T>
Sourcepub fn insert(&mut self, port: Port, value: T) -> Option<T>
pub fn insert(&mut self, port: Port, value: T) -> Option<T>
Inserts value
indexed by port
.
Returns Some(_)
if the value is inserted and there was already
some value stored in the slab.
Sourcepub fn remove(&mut self, port: &Port) -> RemoveOutcome<T>
pub fn remove(&mut self, port: &Port) -> RemoveOutcome<T>
Removes the entry indexed by port
, if one exists.
Note that remove
will not remove an entry if the currently stored
port’s salt doesn’t match port
.
Sourcepub fn get(&self, port: &Port) -> Option<&T>
pub fn get(&self, port: &Port) -> Option<&T>
Gets a reference to the value indexed by port
.
get
only returns Some
if the slab contains an entry for port
with
a matching salt.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for PortSlab<T>
impl<T> RefUnwindSafe for PortSlab<T>where
T: RefUnwindSafe,
impl<T> Send for PortSlab<T>where
T: Send,
impl<T> Sync for PortSlab<T>where
T: Sync,
impl<T> Unpin for PortSlab<T>where
T: Unpin,
impl<T> UnwindSafe for PortSlab<T>where
T: UnwindSafe,
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