I am using example from here
#[derive(Debug)]
enum List {
Cons(i32, RefCell<Rc<List>>),
Nil,
}
impl List {
fn tail(&self) -> Option<&RefCell<Rc<List>>> {
match *self {
Cons(_, ref item) => Some(item),
Nil => None,
}
}
}
Given the function signature is &self , self is of reference type pointing at List and *self is the List instance itself.
But I remember match also take ownership of the object it is matching, so doesn't that cause problem to the struct because the List instance is move to match and not give back?
Also isn't &self immutable, why are we able to move self to match?