pub struct List<T> { /* private fields */ }Expand description
A singly linked immutable list. See the module-level documentation for more.
Implementations§
source§impl<T> List<T>
impl<T> List<T>
sourcepub fn prepend(&self, element: T) -> List<T>
pub fn prepend(&self, element: T) -> List<T>
Prepends a given element to the list, returning a copy of the list with the added element.
sourcepub fn head(&self) -> Option<&T>
pub fn head(&self) -> Option<&T>
Returns a reference to the first element in the list, if it exists.
sourcepub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter(&self) -> Iter<'_, T> ⓘ
Creates an iterator that yields references to all the elements in the list.
Trait Implementations§
Auto Trait Implementations§
impl<T> RefUnwindSafe for List<T>where T: RefUnwindSafe,
impl<T> !Send for List<T>
impl<T> !Sync for List<T>
impl<T> Unpin for List<T>
impl<T> UnwindSafe for List<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