Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created July 16, 2019 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/ed81a8d30c7544eb7227897c49d60b5a to your computer and use it in GitHub Desktop.
Save rust-play/ed81a8d30c7544eb7227897c49d60b5a to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
#![allow(unreachable_code)]
fn main() {
println!("{:?}", {
{ let a = [1,2,3]; a.get(10..) }
});
}
/* ~~~~=== stderr ===~~~~
Compiling playground v0.0.1 (/playground)
error[E0597]: `a` does not live long enough
--> src/main.rs:6:29
|
5 | println!("{:?}", {
| ______________________-
6 | | { let a = [1,2,3]; a.get(10..) }
| | ^ - `a` dropped here while still borrowed
| | |
| | borrowed value does not live long enough
7 | | });
| |_____- borrow later used here
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
*/
/* ~~~~=== stdout ===~~~~
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment