Created
October 6, 2018 20:25
-
-
Save magnet/b8c64daa0dc15ea0ac43a59593721d5c to your computer and use it in GitHub Desktop.
Demonstrating ownership transfer
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 main() { | |
let s = "Foo".to_string(); | |
let newS = foo(s); | |
println!("{}", s); | |
} | |
fn foo(s: String) -> String { | |
let s2 = "Bar".to_string(); | |
println!("{}", s2); | |
s | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment