[][src]Enum mini_kanren::core::stream::Stream

pub enum Stream<T> {
    Empty,
    Pair(T, Box<Stream<T>>),
    Suspension(Box<dyn FnOnce() -> Stream<T>>),
}

Possibly infinite sequence of values.

Variants

Empty
Pair(T, Box<Stream<T>>)
Suspension(Box<dyn FnOnce() -> Stream<T>>)

Implementations

impl<T> Stream<T>[src]

pub fn empty() -> Self[src]

Initialize an empty stream.

pub fn singleton(x: T) -> Self[src]

Create a stream with one element.

pub fn cons(a: T, d: Self) -> Self[src]

Prepend an element to a stream.

pub fn suspension(sup: impl 'static + FnOnce() -> Stream<T>) -> Self[src]

Create a suspended (lazily evaluated) stream.

pub fn from_iter(mut iter: impl Iterator<Item = T>) -> Self[src]

Create a stream with elements from an iterator.

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

Return true if the stream is empty.

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

Return the number of elements in an unsuspended stream, or None if the stream contains any suspensions.

pub fn take_inf(self, n: usize) -> Stream<T>[src]

Truncate a stream to at most n elements, resolving any suspensions.

pub fn take_inf_all(self) -> Stream<T>[src]

Resolve all suspensions in the stream. If the stream is infinite this function will not return and may crash.

pub fn into_vec(self) -> Vec<T>[src]

Convert Stream to Vec.

impl<T: 'static + Default> Stream<T>[src]

pub fn append_inf(s: Stream<T>, t: Stream<T>) -> Self[src]

pub fn append_map_inf(self, g: impl 'static + Clone + Goal<T>) -> Self[src]

pub fn map<U: 'static>(self, f: impl 'static + Fn(T) -> U) -> Stream<U>[src]

Trait Implementations

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

impl<T> IntoIterator for Stream<T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = StreamIter<T>

Which kind of iterator are we turning this into?

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

Auto Trait Implementations

impl<T> !RefUnwindSafe for Stream<T>[src]

impl<T> !Send for Stream<T>[src]

impl<T> !Sync for Stream<T>[src]

impl<T> Unpin for Stream<T> where
    T: Unpin
[src]

impl<T> !UnwindSafe for Stream<T>[src]

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<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.