Т8
Size: a a a
Т8
r
struct Context<'a> {
// other fields
parent: Option<&'a Context<'a>>
}
impl<'a> Context<'a> {
pub fn fork(&self) -> Self {
Self {
// other fields
parent: Some(self)
}
}
}
EG
pub fn fork(self: &Pin<Box<Self>>) -> Pin<Box<Self>> {
Self { parent: self.as_ref().get_ref() }
}
p
EG
self.as_ref()
должен перевести &Pin<Box<Self>>
в Pin<&Self>
, а .get_ref()
должен получить референс с тем же лайфтаймом, что и пинEG
EG
EG
p
EG
p
EG
EG
EG
p
EG
p
pub fn fork(self: &Pin<Box<Self>>) -> Pin<Box<Self>> {
Self { parent: self.as_ref().get_ref() }
}
EG
p
EG
:g/forbid(unsafe_code)/d