pub struct List<T> { /* private fields */ }Expand description
A singly linked list. See the crate-level documentation for more.
Implementations§
source§impl<T> List<T>
impl<T> List<T>
sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes the element at the front of the List,
and returns it.
sourcepub fn peek(&self) -> Option<&T>
pub fn peek(&self) -> Option<&T>
Returns an immutable reference to the value
at the head of the List, if it exists.
sourcepub fn peek_mut(&mut self) -> Option<&mut T>
pub fn peek_mut(&mut self) -> Option<&mut T>
Returns a mutable reference to the value
at the head of the List, if it exists.
Trait Implementations§
source§impl<T> FromIterator<T> for List<T>
impl<T> FromIterator<T> for List<T>
source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a List from an Iterator.
Note that the order of elements is REVERSED. This is subject to change in the future.
use cons_rs::List;
let mut list: List<i32> = vec![1, 2]::collect();
assert_eq!(list.pop(), Some(2));
assert_eq!(list.pop(), Some(1));
assert_eq!(list.pop(), None);Auto Trait Implementations§
impl<T> RefUnwindSafe for List<T>where T: RefUnwindSafe,
impl<T> Send for List<T>where T: Send,
impl<T> Sync for List<T>where T: Sync,
impl<T> Unpin for List<T>
impl<T> UnwindSafe for List<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
Mutably borrows from an owned value. Read more