fn print_out(name: String) {
let (name, devowelized_name) = remove_vowels(name);
println!("Removing vowels yields {:?}", devowelized_name);
// Goal #2: What happens when you uncomment the `println` below?
// Can you change the code above so that the code below compiles
// successfully?
//
let (name, devowelized_name) = remove_vowels(name);
println!("Removing vowels from {:?} yields {:?}",
name, devowelized_name);
// Extra credit: Can you do it without copying any data?
// (Using only ownership transfer)
}
and later was surprised to find out that second call to remove_vowels was unnecessary & devowelized_name could have being passed to println! twice. My (not validated) guess is that macros don't take ownership unlike functions, but I think it's worth explaining in the tutorial.
As I was going through the ownership tutorial and then an associated exercise, I wound up with a following solution:
and later was surprised to find out that second call to
remove_vowels
was unnecessary &devowelized_name
could have being passed toprintln!
twice. My (not validated) guess is that macros don't take ownership unlike functions, but I think it's worth explaining in the tutorial.