2 weeks ago
18 lines476 B
fn shout(text: String) -> String { | |
text.to_uppercase() | |
} | |
| |
fn main() { | |
let greeting = String::from("hello"); | |
let loud = shout(greeting); // greeting moves into shout | |
// println!("{greeting}"); // error[E0382]: borrow of moved value | |
println!("{loud}"); | |
| |
let a = String::from("copy me"); | |
let b = a.clone(); // an explicit, visible copy | |
println!("{a} / {b}"); | |
} | |
| |
// This is the version we use in the video. | |
| |
// Questions? Ask in the course forum. |