Expand description
Functors in Rust
The following traits are provided by this module:
Functorprovides a generalfmapmethod, which is a generalization ofOption::map,Result::map, and so on, and which is implemented for a variety of types in the standard library.FunctorSelfis a special case ofFunctorwhere types aren’t changed when mapping. It is automatically implemented where applicable but must be added as a bound in certain cases.FunctorMutis a special case ofFunctorSelfwhosefmap_mutmethod operates on&mut self. It is not implemented automatically, but this crate provides implementations for all types in the standard library for whichFunctoris implemented.Contravariant,ContravariantSelf, andContravariantMutwhich are the contravariant equivalents of the previous three traits.
Traits
- Contravariant functor (e.g.
Sender<B>which can be converted intoSender<A>by providing anFn(A) -> Btormap) - Same as
ContravariantSelfbut works on&mut self - A
Contravariantfunctor where typeSelf::Consumeeisn’t changed - Generic type (e.g.
T<A>) whose inner type can be mapped over (e.g. resulting inT<B>) - Same as
FunctorSelfbut works on&mut self - A
Functorwhich can be mapped from one type to the same type