Created
April 14, 2022 23:17
-
-
Save jcar787/805ca8f8e70bc2333822a962d2fee464 to your computer and use it in GitHub Desktop.
An example of 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); | |
println!("Not it is not, it still my name: {}", my_name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment