3 ms·
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; Lifetim
by Gankro 11y ago
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).
- jamii 11y agoI think that I'm actually doing the opposite - the lifetime of the state vec is longer than the lifetime of values but it's ok in this case because I pop the values again before they die. What I want to do is temporarily demote the lifetime of the state vec for the recursive call. Here is a really simplified version that illustrates the problem - http://is.gd/8AZvZe http://is.gd/8AZvZe