[][src]Struct lexpr::cons::ListIter

pub struct ListIter<'a>(_);

An iterator yielding the car field of a chain of cons cells.

Improper lists

Since in Lisp, lists can be "improper", i.e., terminated by a value other than Null, this iterator type takes advantage of the fact that Rust's iterators can produce multiple sequences of values, each terminated by None. For an improper list, the terminating value is produced after the sequence of elements, as a singleton element, again followed by None.

For example, while the list (1 2 3) will produce the three expected Some values, followed by None, the list (1 2 . 3) will produce Some values for 1 and 2, then a None, followed by a some value for 3, and then the final None.

Methods

impl<'a> ListIter<'a>[src]

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

Returns true when the iterator is completely exhausted.

For an improper list, true will only be returned after the terminating value has been consumed.

pub fn peek(&self) -> Option<&Value>[src]

Returns a peek at the value that would be returned by a call to next.

For improper lists, this implies that after the last regular element, None will be returned, while is_empty still returns false at that point.

Trait Implementations

impl<'a> Clone for ListIter<'a>[src]

impl<'a> Debug for ListIter<'a>[src]

impl<'a> Iterator for ListIter<'a>[src]

type Item = &'a Value

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for ListIter<'a>

impl<'a> Send for ListIter<'a>

impl<'a> Sync for ListIter<'a>

impl<'a> Unpin for ListIter<'a>

impl<'a> UnwindSafe for ListIter<'a>

Blanket Implementations

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

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

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

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

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

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.