Struct nth_cons_list::List [] [src]

pub struct List<A> { /* fields omitted */ }

An immutable cons list.

Examples

A list can be created using nil and cons.

use nth_cons_list::{cons, nil};

// A list containing `1, 2, 3`
let list = cons(1, cons(2, cons(3, nil())));

Lists can be cheaply shared using .clone().

use std::fmt::Display;
use nth_cons_list::*;

fn print_list<A: Display>(list: List<A>) {
    println!("{}", list);
}

let list = cons(1, cons(2, cons(3, nil())));
print_list(list.clone());

Methods

impl<A> List<A>
[src]

[src]

Returns the first element of the list.

Panics

Panics if the list is empty.

[src]

Returns a list containing all elements except the first.

Panics

Panics if the list is empty.

[src]

Returns the first element of the list, or None if this list is empty.

[src]

Returns a list containing all elements except the first, or None if this list is empty.

[src]

Tests whether this list is empty.

[src]

Returns the length of this list.

[src]

Returns an iterator over the elements of this list.

[src]

Returns a list with the elements in reverse order.

[src]

Creates a new list from a DoubleEndedIterator.

Trait Implementations

impl<A> Clone for List<A>
[src]

[src]

Clones the list by cloning a reference counted pointer to the list's contents; this operation is very cheap.

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a, A: 'a> IntoIterator for &'a List<A>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<A> FromIterator<A> for List<A>
[src]

[src]

Creates a value from an iterator. Read more

impl<A: Display> Display for List<A>
[src]

[src]

Formats the value using the given formatter. Read more

impl<A: Debug> Debug for List<A>
[src]

[src]

Formats the value using the given formatter.

impl<A: PartialEq> PartialEq for List<A>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl<A: Eq> Eq for List<A>
[src]

impl<A: Hash> Hash for List<A>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<A: PartialOrd> PartialOrd for List<A>
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<A: Ord> Ord for List<A>
[src]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl<A> Default for List<A>
[src]

[src]

Returns the "default value" for a type. Read more