prop_check_rs::state

Struct State

Source
pub struct State<S, A> { /* private fields */ }
Expand description

The State monad represents a stateful computation.
Stateモナドは状態付き計算を表します。

Implementations§

Source§

impl<S, A> State<S, A>
where S: 'static, A: Clone + 'static,

Source

pub fn value(a: A) -> State<S, A>

Create a new State with a value.
値を返すStateを作成します。

Source

pub fn new<T, B, F>(f: F) -> State<T, B>
where F: Fn(T) -> (B, T) + 'static,

Create a new State.
新しいStateを作成します。

Source

pub fn pure<B>(b: B) -> State<S, B>
where B: Clone + 'static,

Alias for Self::value.
Self::valueのエイリアス。

Source

pub fn run(self, s: S) -> (A, S)

Run the State.
Stateを実行します。

Source

pub fn map<B, F>(self, f: F) -> State<S, B>
where F: Fn(A) -> B + 'static, B: Clone + 'static,

Map the State.
Stateをマップします。

Source

pub fn flat_map<B, F>(self, f: F) -> State<S, B>
where F: Fn(A) -> State<S, B> + 'static, B: Clone + 'static,

FlatMap the State.
Stateをフラットマップします。

Source

pub fn and_then<B>(self, sb: State<S, B>) -> State<S, (A, B)>
where A: Clone, B: Clone + 'static,

Compose two States.
2つのStateを合成します。

Source

pub fn get<T>() -> State<T, T>
where T: Clone,

Get the state.
状態を取得します。

Source

pub fn set<T>(t: T) -> State<T, ()>
where T: Clone + 'static,

Set the state.
状態を設定します。

Source

pub fn modify<T, F>(f: F) -> State<T, ()>
where F: Fn(T) -> T + 'static, T: Clone + 'static,

Modify the state after get it.
状態を取得した後に変更します。

Source

pub fn sequence(sas: Vec<State<S, A>>) -> State<S, Vec<A>>

Execute the State and return a State with the result in the collection.
Stateを実行し結果をコレクションに持つStateを返します。

Trait Implementations§

Source§

impl<S, A> Clone for State<S, A>
where S: 'static, A: Clone + 'static,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S, A> Debug for State<S, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S, A> Default for State<S, A>
where S: Default + 'static, A: Default + Clone + 'static,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> !UnwindSafe for State<S, A>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V