pub trait Functor<I: Inner> {
// Required method
fn pure(i: I) -> Self;
}Expand description
A container used by a RandomStrategy during computations.
In functional programming, the Functor pattern allows one to apply functions
to values inside a container type, without changing the container’s
structure. A Functor must support an fmap operation, which applies the
function passed to it as a parameter to the contents of the Functor. This
operation is not a method required by Functor due to the limitations of
Rust’s type system.
Additionally, this trait requires that implementors provide the pure
associated function. This provides for a way to begin a series of fmap,
fmap_flat, and fmap_rand operations. This requirement technically puts
this crate’s functors halfway between “normal” functors and applicative
functors, as a subset of the former and a superset of the latter. However,
implementing full applicative functors would be unnecessary for the sorts of
computations that this crate focuses on.
Required Methods§
Sourcefn pure(i: I) -> Self
fn pure(i: I) -> Self
Produce an instance of Self containing the argument as its inner.
This associated function is often used to begin a series of
computations. The associated functions of RandomStrategy only
operate on the Functor associated with that RandomStrategy.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.