Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  5. println!("{:?}", {
  6. let str = String::new(); let split = str.split(' '); let (a, b, c) = (split.next(), split.next(), split.next()); (a, b, c)
  7. });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12. Compiling playground v0.0.1 (/playground)
  13. error[E0597]: `str` does not live long enough
  14. --> src/main.rs:6:46
  15. |
  16. 5 | println!("{:?}", {
  17. | ______________________-
  18. 6 | | let str = String::new(); let split = str.split(' '); let (a, b, c) = (split.next(), split.next(), split.next()); (a, b, c)
  19. | | ^^^ borrowed value does not live long enough
  20. 7 | | });
  21. | | -
  22. | | |
  23. | |_____`str` dropped here while still borrowed
  24. | borrow later used here
  25.  
  26. error[E0596]: cannot borrow `split` as mutable, as it is not declared as mutable
  27. --> src/main.rs:6:79
  28. |
  29. 6 | let str = String::new(); let split = str.split(' '); let (a, b, c) = (split.next(), split.next(), split.next()); (a, b, c)
  30. | ----- ^^^^^ cannot borrow as mutable
  31. | |
  32. | help: consider changing this to be mutable: `mut split`
  33.  
  34. error[E0596]: cannot borrow `split` as mutable, as it is not declared as mutable
  35. --> src/main.rs:6:93
  36. |
  37. 6 | let str = String::new(); let split = str.split(' '); let (a, b, c) = (split.next(), split.next(), split.next()); (a, b, c)
  38. | ----- ^^^^^ cannot borrow as mutable
  39. | |
  40. | help: consider changing this to be mutable: `mut split`
  41.  
  42. error[E0596]: cannot borrow `split` as mutable, as it is not declared as mutable
  43. --> src/main.rs:6:107
  44. |
  45. 6 | let str = String::new(); let split = str.split(' '); let (a, b, c) = (split.next(), split.next(), split.next()); (a, b, c)
  46. | ----- help: consider changing this to be mutable: `mut split` ^^^^^ cannot borrow as mutable
  47.  
  48. error: aborting due to 4 previous errors
  49.  
  50. Some errors occurred: E0596, E0597.
  51. For more information about an error, try `rustc --explain E0596`.
  52. error: Could not compile `playground`.
  53.  
  54. To learn more, run the command again with --verbose.
  55.  
  56. */
  57.  
  58. /* ~~~~=== stdout ===~~~~
  59.  
  60. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement