pub fn main() {
let string = format!("my friend");
greet(&string[3..]);
greet(&string);
}
fn greet(name: &str) {
println!("Hello, {}!", &name);
}
The above code is the exact same as the below code (the difference is the final ampersand in greet).
pub fn main() {
let string = format!("my friend");
greet(&string[3..]);
greet(&string);
}
fn greet(name: &str) {
println!("Hello, {}!", name);
}
Can you explain why this is not different? The first code would basically be a... double borrow?
The above code is the exact same as the below code (the difference is the final ampersand in greet).
Can you explain why this is not different? The first code would basically be a... double borrow?