You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fn main() {
let s: ~str = ~"foobar";
let mut t: &str = s;
t = t.slice(0, 3); // for master: str::view(t, 0, 3) maybe
}
...results in the following error:
t.rs:4:4: 4:5 error: assigning to mutable local variable prohibited due to outstanding loan
t.rs:4 t = t.slice(0, 3);
^
t.rs:4:8: 4:9 note: loan of mutable local variable granted here
t.rs:4 t = t.slice(0, 3);
^
Both t and t.slice(0, 3) are loans of s, so it should be safe to update t to new loan of s as updating t doesn't cause s to be freed.