pub struct FrozenVec<T> { /* private fields */ }
Expand description
Append-only version of std::vec::Vec
where
insertion does not require mutable access
Implementations
sourceimpl<T: StableDeref> FrozenVec<T>
impl<T: StableDeref> FrozenVec<T>
sourcepub fn push_get(&self, val: T) -> &T::Target
pub fn push_get(&self, val: T) -> &T::Target
Push, immediately getting a reference to the element
sourcepub unsafe fn get_unchecked(&self, index: usize) -> &T::Target
pub unsafe fn get_unchecked(&self, index: usize) -> &T::Target
Returns a reference to an element, without doing bounds checking.
Safety
index
must be in bounds, i.e. it must be less than self.len()
sourcepub fn first(&self) -> Option<&T::Target>
pub fn first(&self) -> Option<&T::Target>
Returns the first element of the vector, or None
if empty.
sourcepub fn last(&self) -> Option<&T::Target>
pub fn last(&self) -> Option<&T::Target>
Returns the last element of the vector, or None
if empty.
sourcepub fn iter(&self) -> Iter<'_, T>ⓘNotable traits for Iter<'a, T>impl<'a, T: StableDeref> Iterator for Iter<'a, T> type Item = &'a T::Target;
pub fn iter(&self) -> Iter<'_, T>ⓘNotable traits for Iter<'a, T>impl<'a, T: StableDeref> Iterator for Iter<'a, T> type Item = &'a T::Target;
Returns an iterator over the vector.
sourcepub fn as_mut(&mut self) -> &mut Vec<T>
pub fn as_mut(&mut self) -> &mut Vec<T>
Get mutable access to the underlying vector.
This is safe, as it requires a &mut self
, ensuring nothing is using
the ‘frozen’ contents.
sourcepub fn binary_search(&self, x: &T::Target) -> Result<usize, usize> where
T::Target: Ord,
pub fn binary_search(&self, x: &T::Target) -> Result<usize, usize> where
T::Target: Ord,
Binary searches this sorted vector for a given element, analogous to slice::binary_search.
sourcepub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize> where
F: FnMut(&'a T::Target) -> Ordering,
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize> where
F: FnMut(&'a T::Target) -> Ordering,
Binary searches this sorted vector with a comparator function, analogous to slice::binary_search_by.
sourcepub fn binary_search_by_key<'a, B, F>(
&'a self,
b: &B,
f: F
) -> Result<usize, usize> where
F: FnMut(&'a T::Target) -> B,
B: Ord,
pub fn binary_search_by_key<'a, B, F>(
&'a self,
b: &B,
f: F
) -> Result<usize, usize> where
F: FnMut(&'a T::Target) -> B,
B: Ord,
Binary searches this sorted vector with a key extraction function, analogous to slice::binary_search_by_key.
sourcepub fn partition_point<P>(&self, pred: P) -> usize where
P: FnMut(&T::Target) -> bool,
pub fn partition_point<P>(&self, pred: P) -> usize where
P: FnMut(&T::Target) -> bool,
Returns the index of the partition point according to the given predicate (the index of the first element of the second partition), analogous to slice::partition_point.
Trait Implementations
sourceimpl<A> FromIterator<A> for FrozenVec<A>
impl<A> FromIterator<A> for FrozenVec<A>
sourcefn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = A>,
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = A>,
Creates a value from an iterator. Read more
sourceimpl<T: StableDeref> Index<usize> for FrozenVec<T>
impl<T: StableDeref> Index<usize> for FrozenVec<T>
sourceimpl<'a, T: StableDeref> IntoIterator for &'a FrozenVec<T>
impl<'a, T: StableDeref> IntoIterator for &'a FrozenVec<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for FrozenVec<T>
impl<T> Send for FrozenVec<T> where
T: Send,
impl<T> !Sync for FrozenVec<T>
impl<T> Unpin for FrozenVec<T> where
T: Unpin,
impl<T> UnwindSafe for FrozenVec<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more