Input

Struct Input 

Source
pub struct Input<'a, 'b, T, R>
where T: Eq + Hash,
{ /* private fields */ }
Expand description

Type that have a inner closure
if Input<…> impl From<TYPE> then TYPE can be used as input closure

Implementations§

Source§

impl<'a, 'b, T, R> Input<'a, 'b, T, R>
where T: Eq + Hash,

Source

pub fn new(param: Box<dyn FnMut(&'b T) -> R + 'a>) -> Self

Allows to create new Input from Box<dyn FnMut(&T)->R>

§you mustn’t use it because`
  1. if you have F:FnMut(...) you can use input() from utils

  2. you can use shorter new_input() from utils

  3. It is almost always better to use input() because it takes any type that can convert into Input<…>

But if you have Box<F:FnMut(...)> and push it in input() it converts into Box<Box<dyn FnMut(...)>>, because Box<F:Fn...> impl Fn...
Whatever it happens, use new_input()`

§Examples
 use maller::{Maller, new_input};

 let mut mr=Maller::new();

 let input=Box::new(|x|x+100);
 let input=new_input(input);

 mr.insert(0,input);
Source

pub fn run(&mut self, key: &'b T) -> R

Allows to run closure in input with parameter

§Example
 use maller::input;
 let mut inp=input(|x|x+2);

 assert_eq!(inp.run(&23),25);

Trait Implementations§

Source§

impl<'a, 'b, T, R, F> From<F> for Input<'a, 'b, T, R>
where T: Eq + Hash, F: FnMut(&'b T) -> R + 'a,

Source§

fn from(value: F) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, 'b, T, R> Freeze for Input<'a, 'b, T, R>

§

impl<'a, 'b, T, R> !RefUnwindSafe for Input<'a, 'b, T, R>

§

impl<'a, 'b, T, R> !Send for Input<'a, 'b, T, R>

§

impl<'a, 'b, T, R> !Sync for Input<'a, 'b, T, R>

§

impl<'a, 'b, T, R> Unpin for Input<'a, 'b, T, R>

§

impl<'a, 'b, T, R> !UnwindSafe for Input<'a, 'b, T, R>

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.