I have a struct container of Children and a method pop() that removes the last added Child and returns it's a value:
struct Child {
a: i32,
b: String,
}
struct Container<'a> {
vector: &'a mut Vec<Child>,
}
impl<'a> Container<'a> {
fn pop(&mut self) -> i32 {
return self.vector.pop().a;
}
}
I get the error during compilation:
error: no field `a` on type `std::option::Option<Child>`
--> src/main.rs:12:34
|
12 | return self.vector.pop().a;
| ^
Does the scope of Container's pop() not allow access to values of its Children's scope?