Re:Unsafe Rust: An Intro and Open Questions
by Gankro on Thursday May 28, 2015 @04:37PM
(#9621009)
If you're just trying to demote a lifetime, you should just be able to specify the lifetime on the variable:
let values: &'a Vec<Value> = &values;
Lifetimes have variance so that you can always put a "bigger" lifetime in a place expecting a "smaller" one safely and it will treated as the smaller one forever.
Although it can be a bit of a dangerous game trying to "set" lifetimes manually because lifetime variance is hell (at least to me).
Although it can be a bit of a dangerous game trying to "set" lifetimes manually because lifetime variance is hell (at least to me).