Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  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()
  7. });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12. Compiling playground v0.0.1 (/playground)
  13. error[E0597]: `buf` does not live long enough
  14. --> src/main.rs:6:168
  15. |
  16. 5 | println!("{:?}", {
  17. | ______________________-
  18. 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()
  19. | | ^^^ borrowed value does not live long enough
  20. 7 | | });
  21. | | -
  22. | | |
  23. | |_____`buf` dropped here while still borrowed
  24. | borrow later used here
  25.  
  26. error: aborting due to previous error
  27.  
  28. For more information about this error, try `rustc --explain E0597`.
  29. error: Could not compile `playground`.
  30.  
  31. To learn more, run the command again with --verbose.
  32.  
  33. */
  34.  
  35. /* ~~~~=== stdout ===~~~~
  36.  
  37. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement