HardConceptOwnership, borrowing and lifetimes
Explain variance and why &'a T is covariant but &'a mut T is invariant in T.
This answer is part of Pro
10 of 81 Rust Developer answers are free. A Pro pass opens the rest, including hands-on task steps.
PreviousWhat happens if you violate RefCell borrow rules?Next The compiler says "cannot borrow as mutable because it is also borrowed as immutable" in a loop that pushes to a vector while holding a reference to an element. How do you fix it?