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
fnstringify_name_with_title(name:&Vec<String>) -> String{
name.push(String::from("Esq."));`{}`
let full = name.join(" ");
full
}fnmain(){let name = vec![String::from("Ferris")];let first = &name[0];stringify_name_with_title(&name);println!("{}", first);}
The first suggested fix mutates the name rending the access of first in main problematic.
fnstringify_name_with_title(name:&mutVec<String>) -> String{
name.push(String::from("Esq."));let full = name.join(" ");
full
}
The second solution moves the name causing the same problem.
fnstringify_name_with_title(mutname:Vec<String>) -> String{
name.push(String::from("Esq."));let full = name.join(" ");
full
}
The text was updated successfully, but these errors were encountered:
main
branch to see if this has already been fixed, in this file:I am completely new to Rust and started going through the book just 2-3 days ago. Sorry if I have incorrectly pointed out anything here.
URL to the section(s) of the book with this problem: https://rust-book.cs.brown.edu/ch04-03-fixing-ownership-errors.html#fixing-an-unsafe-program-copying-vs-moving-out-of-a-collection
Description of the problem: The diagram tells us that
v
has lostRead
access, which in reality it should not.Suggested fix: Mark
v
withR
Apart from this, I think the section Fixing an Unsafe Program: Not Enough Permissions does not take into account the previously linked
main
function for the suggested solutions.Here is the described
main
function.The first suggested fix mutates the
name
rending the access offirst
inmain
problematic.The second solution moves the
name
causing the same problem.The text was updated successfully, but these errors were encountered: