Moving Strings
We'll cover the following...
Does this program compile?
Press + to interact
fn greet(name: String) {println!("Hello {}", name);}fn main() {let first_name = "Michael";let last_name = " Snoyman";let full_name: String = first_name.to_owned() + last_name;greet(full_name);}
Sure, no problem! We construct a new String
value, store it in the full_name
variable, and then move it into the greet
function. But what happens if we ...