pub enum LazyStream<T> {
Nil,
Cons(T, Box<dyn FnOnce() -> LazyStream<T>>),
}Expand description
A lazy stream (coinductive list) implemented as a linked structure of thunks.
Models the cofree comonad / productive corecursion pattern.
Variants§
Nil
Empty stream.
Cons(T, Box<dyn FnOnce() -> LazyStream<T>>)
A head value paired with a lazily-computed tail.
Implementations§
Source§impl<T: Clone> LazyStream<T>
impl<T: Clone> LazyStream<T>
Sourcepub fn cons<F: FnOnce() -> LazyStream<T> + 'static>(head: T, tail: F) -> Self
pub fn cons<F: FnOnce() -> LazyStream<T> + 'static>(head: T, tail: F) -> Self
Construct a cons cell.
Auto Trait Implementations§
impl<T> Freeze for LazyStream<T>where
T: Freeze,
impl<T> !RefUnwindSafe for LazyStream<T>
impl<T> !Send for LazyStream<T>
impl<T> !Sync for LazyStream<T>
impl<T> Unpin for LazyStream<T>where
T: Unpin,
impl<T> UnsafeUnpin for LazyStream<T>where
T: UnsafeUnpin,
impl<T> !UnwindSafe for LazyStream<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more