Created
March 26, 2018 12:39
-
-
Save CodeSandwich/5dcd92b946dc72fdae03352bd45ec9d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 borrow_outlives_value() -> &String { | |
let value = "abc".to_string(); // crate value | |
let borrow = &value; // create borrow | |
return borrow // borrow is not deleted | |
// <COMPILE TIME FAIL> delete value, | |
// but it's still borrowed | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment