pub struct ConsList<T> { /* private fields */ }Expand description
An immutable singly-linked list, as seen in basically every functional language
Implementations§
Source§impl<T> ConsList<T>
impl<T> ConsList<T>
Sourcepub fn append(&self, elem: T) -> ConsList<T>
pub fn append(&self, elem: T) -> ConsList<T>
Returns a copy of the list, with elem appended to the front
Sourcepub fn tailn(&self, n: usize) -> ConsList<T>
pub fn tailn(&self, n: usize) -> ConsList<T>
Returns a copy of the list, with the first n elements removed
Sourcepub fn lastn(&self, n: usize) -> ConsList<T>
pub fn lastn(&self, n: usize) -> ConsList<T>
Returns a copy of the list, with only the last n elements remaining
Sourcepub fn iter<'a>(&'a self) -> Iter<'a, T> ⓘ
pub fn iter<'a>(&'a self) -> Iter<'a, T> ⓘ
Returns an iterator over references to the elements of the list in order
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl<T> FromIterator<T> for ConsList<T>
impl<T> FromIterator<T> for ConsList<T>
Source§impl<'a, T> IntoIterator for &'a ConsList<T>
impl<'a, T> IntoIterator for &'a ConsList<T>
Auto Trait Implementations§
impl<T> Freeze for ConsList<T>
impl<T> RefUnwindSafe for ConsList<T>where
T: RefUnwindSafe,
impl<T> !Send for ConsList<T>
impl<T> !Sync for ConsList<T>
impl<T> Unpin for ConsList<T>
impl<T> UnwindSafe for ConsList<T>where
T: RefUnwindSafe,
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