pub struct IdVec<ID: Identifier, Data> { /* private fields */ }Expand description
Similar to Vec except that it is indexed using an Id rather than an usize index. if the stored type implements Default, IdVec can also use the set(…) method which can grow the vector to accomodate for the requested id.
Implementations§
Source§impl<ID: Identifier, Data> IdVec<ID, Data>
impl<ID: Identifier, Data> IdVec<ID, Data>
Sourcepub fn with_capacity(size: ID::Handle) -> IdVec<ID, Data>
pub fn with_capacity(size: ID::Handle) -> IdVec<ID, Data>
Create an IdVec with preallocated storage
Sourcepub fn from_vec(vec: Vec<Data>) -> IdVec<ID, Data>
pub fn from_vec(vec: Vec<Data>) -> IdVec<ID, Data>
Create an IdVec by recycling a Vec and its content.
Sourcepub fn nth(&self, idx: usize) -> &Data
pub fn nth(&self, idx: usize) -> &Data
Return the nth element of the IdVec using an usize index rather than an Id (à la Vec).
Sourcepub fn nth_mut(&mut self, idx: usize) -> &mut Data
pub fn nth_mut(&mut self, idx: usize) -> &mut Data
Return the nth element of the IdVec using an usize index rather than an Id (à la Vec).
Source§impl<ID: Identifier, Data: Default> IdVec<ID, Data>
impl<ID: Identifier, Data: Default> IdVec<ID, Data>
Trait Implementations§
Source§impl<ID: Identifier, Data> Index<ID> for IdVec<ID, Data>
impl<ID: Identifier, Data> Index<ID> for IdVec<ID, Data>
Source§impl<ID: Identifier, Data> IndexMut<ID> for IdVec<ID, Data>
impl<ID: Identifier, Data> IndexMut<ID> for IdVec<ID, Data>
Source§fn index_mut<'l>(&'l mut self, id: ID) -> &'l mut Data
fn index_mut<'l>(&'l mut self, id: ID) -> &'l mut Data
Performs the mutable indexing (
container[index]) operation. Read moreAuto Trait Implementations§
impl<ID, Data> Freeze for IdVec<ID, Data>
impl<ID, Data> RefUnwindSafe for IdVec<ID, Data>where
ID: RefUnwindSafe,
Data: RefUnwindSafe,
impl<ID, Data> Send for IdVec<ID, Data>
impl<ID, Data> Sync for IdVec<ID, Data>
impl<ID, Data> Unpin for IdVec<ID, Data>
impl<ID, Data> UnwindSafe for IdVec<ID, Data>where
ID: UnwindSafe,
Data: 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