Struct cons_list::ConsList
[−]
[src]
pub struct ConsList<T> { /* fields omitted */ }
An immutable singly-linked list, as seen in basically every functional language
Methods
impl<T> ConsList<T>
[src]
fn new() -> ConsList<T>
Constructs a new, empty ConsList
fn append(&self, elem: T) -> ConsList<T>
Returns a copy of the list, with elem
appended to the front
fn head(&self) -> Option<&T>
Returns a reference to the first element in the list
fn tail(&self) -> ConsList<T>
Returns a copy of the list, with the first element removed
fn tailn(&self, n: usize) -> ConsList<T>
Returns a copy of the list, with the first n
elements removed
fn last(&self) -> Option<&T>
Returns the last element in the list
fn lastn(&self, n: usize) -> ConsList<T>
Returns a copy of the list, with only the last n
elements remaining
fn iter<'a>(&'a self) -> Iter<'a, T>
Returns an iterator over references to the elements of the list in order
fn len(&self) -> usize
fn is_empty(&self) -> bool
Trait Implementations
impl<T> Drop for ConsList<T>
[src]
impl<T> FromIterator<T> for ConsList<T>
[src]
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> ConsList<T>
Creates a value from an iterator. Read more
impl<T: PartialEq> PartialEq for ConsList<T>
[src]
fn eq(&self, other: &ConsList<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &ConsList<T>) -> bool
This method tests for !=
.
impl<T: PartialOrd> PartialOrd for ConsList<T>
[src]
fn partial_cmp(&self, other: &ConsList<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T> Clone for ConsList<T>
[src]
fn clone(&self) -> ConsList<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for ConsList<T>
[src]
impl<A: Hash> Hash for ConsList<A>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.