Hi,
recently I faced with a problem that I need to enclose the 'self lifetime inside the struct itself:
struct MyStruct<'self> { // but it should't be exposed
data: Vec<Item>,
id_map: HashMap<u32, &'self Item> // id_map it refer to some self.data's Item
}
enclosing lifetimes for traits is looks something like for<'a> MyTrait<'a>;
Proposal:
Implicilty add 'self to every struct, and propogate it to all inner structs:
struct MyStruct { // it will has <'self> implicitly
inner: AnotherStruct, // it will has <'self> also implicitly
other: &'self Item, // or ecplicitly
}
Any other suggestions to enclose 'self lifetime?