E0502E0502 — Cannot Borrow as Mutable Because Also Borrowed as Immutable
A value cannot be mutably borrowed while an immutable borrow is still active.
E0515A function tries to return a reference to a value that is created inside the function.
The local variable will be dropped when the function returns, so a reference to it would be dangling. Rust prevents returning references to data that does not outlive the function call.
Return an owned value (String, Vec, Box) instead of a reference. Move the data to a longer-lived scope. Use a static reference if the data is a compile-time constant.
fn foo() -> &str {
let s = String::from("hi");
&s
}E0502A value cannot be mutably borrowed while an immutable borrow is still active.
unused_variablesA variable is declared but never used in the code.
E0658A feature that is not yet stabilized in Rust is being used without the feature gate.
E0106A reference in a function signature or struct is missing a lifetime parameter.
E0614The dereference operator (*) is used on a type that does not implement Deref.
clippy::let_and_returnA variable is declared and immediately returned on the next line.