Struct std::kinds::marker::CovariantLifetimeExperimental
[-]
[+]
[src]
pub struct CovariantLifetime<'a>;
As CovariantType
, but for lifetime parameters. Using
CovariantLifetime<'a>
indicates that it is ok to substitute
a longer lifetime for 'a
than the one you originally
started with (e.g., you could convert any lifetime 'foo
to
'static
). You almost certainly want ContravariantLifetime
instead, or possibly InvariantLifetime
. The only case where
it would be appropriate is that you have a (type-casted, and
hence hidden from the type system) function pointer with a
signature like fn(&'a T)
(and no other uses of 'a
). In
this case, it is ok to substitute a larger lifetime for 'a
(e.g., fn(&'static T)
), because the function is only
becoming more selective in terms of what it accepts as
argument.
For more information about variance, refer to this Wikipedia article http://en.wikipedia.org/wiki/Variance_%28computer_science%29.