Struct texcraft_stdext::collections::nevec::Nevec
source · pub struct Nevec<T> { /* private fields */ }
Expand description
Non-empty vector type.
Implementations§
source§impl<T> Nevec<T>
impl<T> Nevec<T>
sourcepub fn with_capacity(first: T, capacity: usize) -> Nevec<T>
pub fn with_capacity(first: T, capacity: usize) -> Nevec<T>
Creates a new Nevec
with the provided first element and initial capacity.
sourcepub fn new_with_tail(first: T, tail: Vec<T>) -> Nevec<T>
pub fn new_with_tail(first: T, tail: Vec<T>) -> Nevec<T>
Creates a new Nevec
with the provided first element and remaining elements (“the tail”).
sourcepub fn last(&self) -> &T
pub fn last(&self) -> &T
Gets a reference to the last element of the vector. Because the vector is guaranteed to be non-empty, this will always succeed.
sourcepub fn last_mut(&mut self) -> &mut T
pub fn last_mut(&mut self) -> &mut T
Gets a mutable reference to the last element of the vector. Because the vector is guaranteed to be non-empty, this will always succeed.
sourcepub fn pop(self) -> T
pub fn pop(self) -> T
Pops an element from the end of the vector.
Because the vector is guaranteed to be non-empty, this will always succeed. However if the vector has only 1 element, then after popping it will no longer be non-empty. For this reason, the pop method takes ownership of the vector, and destroys it in the process.
In the case when the vector has more than 1 element, the method pop_from_tail
can be used to retrieve the last element without destroying the vector.
sourcepub fn pop_from_tail(&mut self) -> Option<T>
pub fn pop_from_tail(&mut self) -> Option<T>
Pops an element from the tail of the vector; that is, the part of the vector after the first element.
Returns None
if and only if the vector has exactly 1 element. In this
case the method pop
is needed to take ownership of the element.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of the vector, which is guaranteed to be at least 1.
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for Nevec<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Nevec<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>,
source§impl<'a, T> IntoIterator for &'a Nevec<T>
impl<'a, T> IntoIterator for &'a Nevec<T>
Auto Trait Implementations§
impl<T> Freeze for Nevec<T>where
T: Freeze,
impl<T> RefUnwindSafe for Nevec<T>where
T: RefUnwindSafe,
impl<T> Send for Nevec<T>where
T: Send,
impl<T> Sync for Nevec<T>where
T: Sync,
impl<T> Unpin for Nevec<T>where
T: Unpin,
impl<T> UnwindSafe for Nevec<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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)