I was wondering, we can refer to an object from within its own code using self
and we can refer to that object's type using Self
but is there any way to refer to the lifetime of that object? I don't mean the lifetime of a reference to that object, but to the lifetime of the object itself.
As an example of what I'm trying to do, is there a lifetime I can use to make the following code compile?
use std::slice::Iter;
trait MakeIntoIter {
type Item;
type IntoIter: Iterator<Item=Self::Item>;
fn iter(&self) -> Self::IntoIter;
}
struct Thing (Vec<usize>);
impl MakeIntoIter for Thing {
type Item = usize;
type IntoIter = Iter<usize>;
fn iter(&self) -> Iter<usize> {
self.0.iter()
}
}