In the given image on Line 25, I was expected as_mut()
to give error like cannot borrow node.next as mutable, as it is not declared as mutable
.
I know my understanding is wrong but I'm not able to figure it out.
In order to call as_mut()
all you need is an &mut
reference. Since node
is an &mut
reference, you can borrow one of its fields. Note that node
itself doesn't need to be declared mut
in the if let
because you are not replacing the &mut
reference stored in node
.
4 Likes
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.