pub struct OptionVec<T> { /* private fields */ }Expand description
A vector that can contain unused indices.
Implementations§
Source§impl<T> OptionVec<T>
impl<T> OptionVec<T>
pub fn len(&self) -> usize
pub fn size(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn contains(&self, index: usize) -> bool
pub fn get(&self, index: usize) -> Option<&T>
pub fn get_mut(&mut self, index: usize) -> Option<&mut T>
pub fn capacity(&self) -> usize
pub fn reserve(&mut self, additional: usize)
pub fn clear(&mut self)
pub fn iter(&self) -> Iter<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Sourcepub fn insert(&mut self, index: usize, element: T)
pub fn insert(&mut self, index: usize, element: T)
Write the element at the given index. If there is already an element at the given index, it will be overwritten. If there isn’t, a new element will be added at that index.
Sourcepub fn try_remove(&mut self, index: usize) -> Result<T, String>
pub fn try_remove(&mut self, index: usize) -> Result<T, String>
Remove the element at the given index and return it. If the OptionVec is not big enough to contain this index, this will throw an error. If there isn’t an element at that index, this will throw an error.
pub fn option_remove(&mut self, index: usize) -> Option<T>
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for OptionVec<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for OptionVec<T>where
T: Deserialize<'de>,
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'de, T> Deserialize<'de> for OptionVec<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for OptionVec<T>where
T: Deserialize<'de>,
Source§fn deserialize<D>(deserializer: D) -> Result<Self, DeError>where
D: DeserializerTrait<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, DeError>where
D: DeserializerTrait<'de>,
Deserialize this value from the given deserializer.
Source§impl<T> Extend<(usize, T)> for OptionVec<T>
impl<T> Extend<(usize, T)> for OptionVec<T>
Source§fn extend<I: IntoIterator<Item = (usize, T)>>(&mut self, iterable: I)
fn extend<I: IntoIterator<Item = (usize, T)>>(&mut self, iterable: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<T> FromIterator<(usize, T)> for OptionVec<T>
impl<T> FromIterator<(usize, T)> for OptionVec<T>
Source§impl<'a, T> IntoIterator for &'a OptionVec<T>
impl<'a, T> IntoIterator for &'a OptionVec<T>
Source§impl<'a, T> IntoIterator for &'a mut OptionVec<T>
impl<'a, T> IntoIterator for &'a mut OptionVec<T>
impl<T: Eq> Eq for OptionVec<T>
impl<T> StructuralPartialEq for OptionVec<T>
Auto Trait Implementations§
impl<T> Freeze for OptionVec<T>
impl<T> RefUnwindSafe for OptionVec<T>where
T: RefUnwindSafe,
impl<T> Send for OptionVec<T>where
T: Send,
impl<T> Sync for OptionVec<T>where
T: Sync,
impl<T> Unpin for OptionVec<T>where
T: Unpin,
impl<T> UnwindSafe for OptionVec<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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.