3 ms·
Small correction: contrary to what the post claims this does not compile: fn main() { let s = String::from("hello"); foo(s); printl
by timakro 4y ago
Small correction: contrary to what the post claims this does not compile:
fn main() {
let s = String::from("hello");
foo(s);
println!("{}", s);
}
fn foo(le_string: String) -> String {
println!("{}", le_string);
le_string
}
This does, which is probably what the author meant:
fn main() {
let s = String::from("hello");
let s = foo(s);
println!("{}", s);
}
fn foo(le_string: String) -> String {
println!("{}", le_string);
le_string
}
Great post!
- kapolos 4y agoIndeed, thank you for catching it! I will make an update. Thanks again!