Created
April 14, 2022 23:15
-
-
Save jcar787/9c71e7dcdd8c0c39dcb62dcf780a92ec to your computer and use it in GitHub Desktop.
Losing ownership to a function (no borrowing) in rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn give_me_your_name(name: String) { | |
println!("Look at me, this is my name now! {}", name); | |
} | |
fn main() { | |
let my_name = String::from("Jeff"); | |
give_me_your_name(my_name); | |
// Uncomment the next line and its gonna give you an error | |
// println!("This was my name: {}, my_name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment