pub trait Pure<A> {
fn pure(value: A) -> Self;
}
Expand description
Pure
lets you construct a value of type F<A>
from a single value of A
.
Think of it as Default
, but instead of constructing an empty
value, it takes a single argument value and wraps it in the container type
in a meaningful way.
For instance:
Option::pure(5)
returnsSome(5)
.Result::pure(5)
returnsOk(5)
.Vec::pure(5)
returnsvec![5]
.