I have the following struct in one of the crates that I’m using.
pub struct Set<'a, 'b: 'a, 'c: 'a + 'b> { sockets: ManagedSlice<'a, Option<Item<'b, 'c>>> } impl<'a, 'b: 'a, 'c: 'a + 'b> Set<'a, 'b, 'c> { pub fn new<SocketsT>(sockets: SocketsT) -> Set<'a, 'b, 'c> where SocketsT: Into<ManagedSlice<'a, Option<Item<'b, 'c>>>> { let sockets = sockets.into(); Set { sockets: sockets } } }
I need to have struct Set
as one of the fields in another struct. For example,
pub struct foo {
sockets:Set,
}impl foo { pub fn init(&mut self){ self.sockets = Set::new(vec![]); } }
But this results in the following error.
| 21 | sockets:Set, | ^^^^^^^^^ expected 3 lifetime parameters
I read about advance lifetimes in rust, but could not figure out how to work this out. How to correctly set the lifetimes here?