Struct flatten_objects::FlattenObjects
source · pub struct FlattenObjects<T, const CAP: usize> { /* private fields */ }
Expand description
A container that stores numbered objects.
See the crate-level documentation for more details.
CAP
is the maximum number of objects that can be held. It also equals the
maximum ID that can be assigned plus one. Currently, CAP
must not be
greater than 1024.
Implementations§
source§impl<T, const CAP: usize> FlattenObjects<T, CAP>
impl<T, const CAP: usize> FlattenObjects<T, CAP>
sourcepub const fn capacity(&self) -> usize
pub const fn capacity(&self) -> usize
Returns the maximum number of objects that can be held.
It also equals the maximum ID that can be assigned plus one.
sourcepub fn is_assigned(&self, id: usize) -> bool
pub fn is_assigned(&self, id: usize) -> bool
Returns true
if the given id
is already be assigned.
sourcepub fn get(&self, id: usize) -> Option<&T>
pub fn get(&self, id: usize) -> Option<&T>
Returns the reference of the element with the given id
if it already
be assigned. Otherwise, returns None
.
sourcepub fn get_mut(&mut self, id: usize) -> Option<&mut T>
pub fn get_mut(&mut self, id: usize) -> Option<&mut T>
Returns the mutable reference of the element with the given id
if it
exists. Otherwise, returns None
.
sourcepub fn add(&mut self, value: T) -> Option<usize>
pub fn add(&mut self, value: T) -> Option<usize>
Add an object and assigns it a unique ID.
Returns the ID if there is one available. Otherwise, returns None
.
Auto Trait Implementations§
impl<T, const CAP: usize> RefUnwindSafe for FlattenObjects<T, CAP>where
T: RefUnwindSafe,
impl<T, const CAP: usize> Send for FlattenObjects<T, CAP>where
T: Send,
impl<T, const CAP: usize> Sync for FlattenObjects<T, CAP>where
T: Sync,
impl<T, const CAP: usize> Unpin for FlattenObjects<T, CAP>where
T: Unpin,
impl<T, const CAP: usize> UnwindSafe for FlattenObjects<T, CAP>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