Variance
Variance is a set of PhantomData
-like marker types that make it easier to
specify the variance of your generic types with respect to their parameters.
Getting Started
The Variance crate is available on crates.io. Add the following dependency to your Cargo manifest:
[]
= "0.1.0"
See the docs for detailed usage information.
Example
The crate provides three zero-sized marker types: Covariant<T>
,
Contravariant<T>
, and Invariant<T>
, each marking the given type parameter
as having the respective variance.
For example:
use ;
// UnaryFunction is a zero-sized type that is covariant to `Arg` and
// contravariant to `Ret`.
License
This crate is MIT licensed.