Struct LazyMut

Source
pub struct LazyMut<I, O, F>
where F: FnMut(I) -> O,
{ /* private fields */ }
Expand description

A “lazily” create pipe with a mutable state.

This pipe’s behavior is defined by a callable object, for example a lambda expression, and can therefore be “lazily” created inline.

Since callable objects with mutable state can not be reseted, reset will panic if it’s called.

§Example

use iterpipes::*;

let mut counter: u8 = 0;
let mut pipe = LazyMut::new(|i: u8| {
    counter += 1;
    i*counter
});

assert_eq!(1, pipe.next(1));
assert_eq!(4, pipe.next(2));

Implementations§

Source§

impl<I, O, F> LazyMut<I, O, F>
where F: FnMut(I) -> O,

Source

pub fn new(function: F) -> Self

Create a new lazy pipe.

Trait Implementations§

Source§

impl<I, O, F> Pipe for LazyMut<I, O, F>
where F: FnMut(I) -> O,

Source§

type InputItem = I

The type of input this pipe accepts.
Source§

type OutputItem = O

The type of output this pipe produces.
Source§

fn next(&mut self, input: I) -> O

Calculate the next output item, based on an input item.
Source§

fn bypass(self) -> Bypass<Self>
where Self: Sized, Self::InputItem: Clone,

Create a bypassed version of the pipe. Read more
Source§

fn compose(self) -> Composed<Self>
where Self: Sized,

Create a composable pipe. Read more
Source§

fn connect<O: Pipe<InputItem = Self::OutputItem>>( self, other: O, ) -> Connector<Self, O>
where Self: Sized,

Connect two pipes. Read more
Source§

fn into_iter(self) -> IterPipe<Self>
where Self::InputItem: Default, Self: Sized + Pipe<InputItem = ()>,

Wrap the pipe into an iterator. Read more
Source§

fn optional(self) -> Optional<Self>
where Self: Sized,

Optionalize the pipe. Read more
Source§

fn enumerate(self) -> Enumerate<Self>
where Self: Sized,

Enumerate the output items of a pipe. Read more
Source§

fn boxed( self, ) -> Box<dyn Pipe<InputItem = Self::InputItem, OutputItem = Self::OutputItem>>
where Self: Sized + 'static,

Create a boxed trait object of the pipe. Read more

Auto Trait Implementations§

§

impl<I, O, F> Freeze for LazyMut<I, O, F>
where F: Freeze,

§

impl<I, O, F> RefUnwindSafe for LazyMut<I, O, F>

§

impl<I, O, F> Send for LazyMut<I, O, F>
where F: Send, I: Send, O: Send,

§

impl<I, O, F> Sync for LazyMut<I, O, F>
where F: Sync, I: Sync, O: Sync,

§

impl<I, O, F> Unpin for LazyMut<I, O, F>
where F: Unpin, I: Unpin, O: Unpin,

§

impl<I, O, F> UnwindSafe for LazyMut<I, O, F>
where F: UnwindSafe, I: UnwindSafe, O: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.