pub struct IndexVec<I: Idx, T> { /* private fields */ }Expand description
A Vec that can only be indexed by a specific index type I.
Implementations§
Source§impl<I: Idx, T> IndexVec<I, T>
impl<I: Idx, T> IndexVec<I, T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create with pre-allocated capacity.
Sourcepub fn get_mut(&mut self, idx: I) -> Option<&mut T>
pub fn get_mut(&mut self, idx: I) -> Option<&mut T>
Get a mutable reference to the value at the given index.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
Returns a mutable iterator over the values.
Sourcepub fn iter_enumerated(&self) -> impl Iterator<Item = (I, &T)>
pub fn iter_enumerated(&self) -> impl Iterator<Item = (I, &T)>
Returns an iterator over (index, value) pairs.
Trait Implementations§
Source§impl<I: Idx, T> FromIterator<T> for IndexVec<I, T>
impl<I: Idx, T> FromIterator<T> for IndexVec<I, T>
Source§fn from_iter<It: IntoIterator<Item = T>>(iter: It) -> Self
fn from_iter<It: IntoIterator<Item = T>>(iter: It) -> Self
Creates a value from an iterator. Read more
Auto Trait Implementations§
impl<I, T> Freeze for IndexVec<I, T>
impl<I, T> RefUnwindSafe for IndexVec<I, T>where
T: RefUnwindSafe,
impl<I, T> Send for IndexVec<I, T>where
T: Send,
impl<I, T> Sync for IndexVec<I, T>where
T: Sync,
impl<I, T> Unpin for IndexVec<I, T>where
T: Unpin,
impl<I, T> UnsafeUnpin for IndexVec<I, T>
impl<I, T> UnwindSafe for IndexVec<I, 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more