Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unreachable_code)]
- fn main() {
- println!("{:?}", {
- use std::io::prelude::*; use std::fs::File; let mut file = File::open("/etc/os-release").unwrap(); let mut buf = String::new(); file.read_to_string(&mut buf); buf.lines().next()
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (/playground)
- error[E0597]: `buf` does not live long enough
- --> src/main.rs:6:168
- |
- 5 | println!("{:?}", {
- | ______________________-
- 6 | | use std::io::prelude::*; use std::fs::File; let mut file = File::open("/etc/os-release").unwrap(); let mut buf = String::new(); file.read_to_string(&mut buf); buf.lines().next()
- | | ^^^ borrowed value does not live long enough
- 7 | | });
- | | -
- | | |
- | |_____`buf` dropped here while still borrowed
- | 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 ===~~~~
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement