MediumScenarioOwnership, borrowing and lifetimes
A function returns a reference to a local String and fails to compile. What are the options?
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.
PreviousThe 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?Next A struct needs to hold a reference to data owned by a sibling field and the borrow checker refuses. What do you do?