[][src]Struct fplist::PersistentList

pub struct PersistentList<T> { /* fields omitted */ }

An immutable singly-linked list.

Methods

impl<T> PersistentList<T>[src]

pub const fn new() -> Self[src]

Create a new empty list. Does not allocate.

pub fn first(&self) -> Option<&T>[src]

Retrieve the current element.

Returns None in an empty list.

pub fn rest(&self) -> Self[src]

Retrieve the next list in line.

Decreases the length by one unless it's the empty list.

Important traits for ListIter<'a, T>
pub fn iter(&self) -> ListIter<T>[src]

Provide an iterator to all of the elements in the list.

pub const fn len(&self) -> usize[src]

Retrieve how many elements there are in total.

O(1)

pub const fn is_empty(&self) -> bool[src]

Is the list empty?

pub fn take(&mut self) -> Self[src]

Return an owned instance of this list, leaving an empty one in its place.

impl<T: Clone> PersistentList<T>[src]

pub fn pop(self) -> Option<(T, Self)>[src]

Split the list to its current element and the next succeeding list.

This will attempt to take ownership of the element, but if there are other existing references to it, its clone will be returned.

pub fn pfirst(self) -> Option<T>[src]

Similar to first but tries to take ownership of the element if possible, otherwise clones it.

pub fn append(self, r: PersistentList<T>) -> PersistentList<T>[src]

Merge this list's elements with another, creating a new list with all the elements combined.

Note: All of the elements from this list will have their ownership taken, or be cloned into the new list depending on the number of references to said elements.

The mergee list's elements will NOT be cloned; their memory will be shared in the new list!

impl<T: PartialEq, U> PersistentList<(T, U)>[src]

pub fn assoq(&self, key: &T) -> Option<&U>[src]

Find the value belonging to the provided key in this Association List.

Trait Implementations

impl<T> Default for PersistentList<T>[src]

impl<T> Clone for PersistentList<T>[src]

fn clone(&self) -> Self[src]

Make a new copy of the list.

O(1)

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T> Drop for PersistentList<T>[src]

impl<T: Clone> Extend<T> for PersistentList<T>[src]

impl<T: PartialEq> PartialEq<PersistentList<T>> for PersistentList<T>[src]

impl<T: Clone> IntoIterator for PersistentList<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = OwnedListIter<T>

Which kind of iterator are we turning this into?

impl<'a, T> IntoIterator for &'a PersistentList<T>[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = ListIter<'a, T>

Which kind of iterator are we turning this into?

impl<T: Debug> Debug for PersistentList<T>[src]

impl<T: Display> Display for PersistentList<T>[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Formats this list to a parenthesis representation.

A list of 1->2->3->() would result in the repr.: (1 2 3)

impl<T> FromIterator<T> for PersistentList<T>[src]

Auto Trait Implementations

impl<T> !Send for PersistentList<T>

impl<T> !Sync for PersistentList<T>

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]