pub struct State<S, A> { /* private fields */ }Expand description
A State monad: transforms state S into (A, S).
Implementations§
Source§impl<S: 'static, A: 'static> State<S, A>
impl<S: 'static, A: 'static> State<S, A>
Sourcepub fn new(f: impl FnOnce(S) -> (A, S) + 'static) -> Self
pub fn new(f: impl FnOnce(S) -> (A, S) + 'static) -> Self
Create a State from a state transformation function.
Sourcepub fn bind<B: 'static>(
self,
f: impl FnOnce(A) -> State<S, B> + 'static,
) -> State<S, B>
pub fn bind<B: 'static>( self, f: impl FnOnce(A) -> State<S, B> + 'static, ) -> State<S, B>
Monadic bind.
Auto Trait Implementations§
impl<S, A> Freeze for State<S, A>
impl<S, A> !RefUnwindSafe for State<S, A>
impl<S, A> !Send for State<S, A>
impl<S, A> !Sync for State<S, A>
impl<S, A> Unpin for State<S, A>
impl<S, A> UnsafeUnpin for State<S, A>
impl<S, A> !UnwindSafe for State<S, A>
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