[−][src]Struct unicycle::pin_slab::PinSlab
Pre-allocated storage for a uniform data type, with slots of immovable memory regions.
Implementations
impl<T> PinSlab<T>
[src]
pub fn new() -> Self
[src]
Construct a new, empty PinSlab with the default slot size.
Examples
use unicycle::pin_slab::PinSlab; let mut slab = PinSlab::new(); assert!(!slab.remove(0)); let index = slab.insert(42); assert!(slab.remove(index)); assert!(!slab.remove(index));
pub fn len(&self) -> usize
[src]
Get the length of the slab.
Examples
use unicycle::pin_slab::PinSlab; let mut slab = PinSlab::new(); assert_eq!(0, slab.len()); assert_eq!(0, slab.insert(42)); assert_eq!(1, slab.len());
pub fn is_empty(&self) -> bool
[src]
Test if the pin slab is empty.
Examples
use unicycle::pin_slab::PinSlab; let mut slab = PinSlab::new(); assert!(slab.is_empty()); assert_eq!(0, slab.insert(42)); assert!(!slab.is_empty());
pub fn insert(&mut self, val: T) -> usize
[src]
Insert a value into the pin slab.
pub fn get_pin_mut(&mut self, key: usize) -> Option<Pin<&mut T>>
[src]
Access the given key as a pinned mutable value.
pub fn get(&mut self, key: usize) -> Option<&T>
[src]
Get a reference to the value at the given slot.
Examples
use unicycle::pin_slab::PinSlab; let mut slab = PinSlab::new(); let key = slab.insert(42); assert_eq!(Some(&42), slab.get(key));
pub fn get_mut(&mut self, key: usize) -> Option<&mut T> where
T: Unpin,
[src]
T: Unpin,
Get a mutable reference to the value at the given slot.
Examples
use unicycle::pin_slab::PinSlab; let mut slab = PinSlab::new(); let key = slab.insert(42); *slab.get_mut(key).unwrap() = 43; assert_eq!(Some(&43), slab.get(key));
pub fn remove(&mut self, key: usize) -> bool
[src]
Remove the key from the slab.
Returns true
if the entry was removed, false
otherwise.
Removing a key which does not exist has no effect, and false
will be
returned.
We need to take care that we don't move it, hence we only perform operations over pointers below.
Examples
use unicycle::pin_slab::PinSlab; let mut slab = PinSlab::new(); assert!(!slab.remove(0)); let index = slab.insert(42); assert!(slab.remove(index)); assert!(!slab.remove(index));
pub fn clear(&mut self)
[src]
Clear all available data in the PinSlot.
Examples
use unicycle::pin_slab::PinSlab; let mut slab = PinSlab::new(); assert_eq!(0, slab.insert(42)); slab.clear(); assert!(slab.get(0).is_none());
Trait Implementations
impl<T: Clone> Clone for PinSlab<T>
[src]
impl<T> Default for PinSlab<T>
[src]
impl<T> Drop for PinSlab<T>
[src]
impl<T> Send for PinSlab<T>
[src]
impl<T> Sync for PinSlab<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for PinSlab<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Unpin for PinSlab<T>
impl<T> UnwindSafe for PinSlab<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,