Guest User

Untitled

a guest
Aug 15th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  5. println!("{:?}", {
  6. fn foo<A, B>(a: A) -> Option<&B> where for<'b> A: IntoIterator<Item=&'b B> { a.into_iter().last() } let vec = vec![0, 1, 2, 3]; foo(&vec);
  7. });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12. Compiling playground v0.0.1 (file:///playground)
  13. error[E0106]: missing lifetime specifier
  14. --> src/main.rs:6:38
  15. |
  16. 6 | fn foo<A, B>(a: A) -> Option<&B> where for<'b> A: IntoIterator<Item=&'b B> { a.into_iter().last() } let vec = vec![0, 1, 2, 3]; foo(&vec);
  17. | ^ expected lifetime parameter
  18. |
  19. = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
  20. = help: consider giving it an explicit bounded or 'static lifetime
  21.  
  22. error[E0582]: binding for associated type `Item` references lifetime `'b`, which does not appear in the trait input types
  23. --> src/main.rs:6:72
  24. |
  25. 6 | fn foo<A, B>(a: A) -> Option<&B> where for<'b> A: IntoIterator<Item=&'b B> { a.into_iter().last() } let vec = vec![0, 1, 2, 3]; foo(&vec);
  26. | ^^^^^^^^^^
  27.  
  28. error: aborting due to 2 previous errors
  29.  
  30. Some errors occurred: E0106, E0582.
  31. For more information about an error, try `rustc --explain E0106`.
  32. error: Could not compile `playground`.
  33.  
  34. To learn more, run the command again with --verbose.
  35.  
  36. */
  37.  
  38. /* ~~~~=== stdout ===~~~~
  39.  
  40. */
Add Comment
Please, Sign In to add comment