pub struct OnceList<T, A: Allocator = Global> { /* private fields */ }Expand description
A single linked list which behaves like std::cell::OnceCell, but for multiple values.
See the crate document for the examples.
Implementations§
Source§impl<T, A: Allocator> OnceList<T, A>
impl<T, A: Allocator> OnceList<T, A>
Sourcepub fn new_in(alloc: A) -> Self
pub fn new_in(alloc: A) -> Self
Creates a new empty OnceList with the given allocator. This method does not allocate.
Sourcepub fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
pub fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
Returns true if the list contains the value.
Sourcepub fn first_mut(&mut self) -> Option<&mut T>
pub fn first_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the first value, if it exists.
Sourcepub fn last_mut(&mut self) -> Option<&mut T>
pub fn last_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the last value, if it exists. This method is O(n).
Sourcepub fn iter(&self) -> impl Iterator<Item = &T>
pub fn iter(&self) -> impl Iterator<Item = &T>
Returns an iterator over the &T references in the list.
Source§impl<T: Sized, A: Allocator + Clone> OnceList<T, A>
impl<T: Sized, A: Allocator + Clone> OnceList<T, A>
Sourcepub fn push(&self, val: T) -> &T
pub fn push(&self, val: T) -> &T
Appends a value to the list, and returns the reference to that value.
Note that this method takes &self, not &mut self.
Sourcepub fn extend<U: IntoIterator<Item = T>>(&self, iter: U)
pub fn extend<U: IntoIterator<Item = T>>(&self, iter: U)
An almost same method with the std::iter::Extend::extend,
though this method takes &self instead of &mut self.
Trait Implementations§
Source§impl<T, A: Allocator + Clone> Extend<T> for OnceList<T, A>
impl<T, A: Allocator + Clone> Extend<T> for OnceList<T, A>
Source§fn extend<U: IntoIterator<Item = T>>(&mut self, iter: U)
fn extend<U: IntoIterator<Item = T>>(&mut self, iter: U)
Due to the definition of the Extend trait, this method takes &mut self.
Use the OnceList::extend method instead if you want to use &self.
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)