I would like to write a method on a struct which borrows a value wrapped in an Option
in one of its properties/fields.
Is it doable ?
Consider
struct A {}
struct Obj {
a: Option<A>
}
impl Obj {
fn ref_to_a(&self) -> &A {
//&self.a.unwrap() <-- How do I implement this ?
}
}