With reference to this question, I tried to compile it with some changes:
pub trait GetIter<'a> {
type IntoIter: IntoIterator<Item = usize>;
fn get_iter(&'a self) -> Self::IntoIter;
}
pub struct NoRef<T> {
inner: T,
}
impl<'a, T: 'a> GetIter<'a> for NoRef<T>
where
&'a T: GetIter<'a>,
{
type IntoIter = Vec<usize>;
fn get_iter(&'a self) -> Vec<usize> {
(&self.inner).get_iter();
vec![]
}
}
It gives the following error:
error[E0716]: temporary value dropped while borrowed
--> src/lib.rs:16:9
|
10 | impl<'a, T: 'a> GetIter<'a> for NoRef<T>
| -- lifetime `'a` defined here
...
16 | (&self.inner).get_iter();
| ^^^^^^^^^^^^^------------ temporary value is freed at the end of this statement
| |
| creates a temporary value which is freed while still in use
| argument requires that borrow lasts for `'a`
I am not getting what "temporary value" it is referring to here?