Guest User

Untitled

a guest
May 24th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. fn main() {
  2. println!("{:?}", {
  3. fn foo<T: std::fmt::Debug>() -> impl AsRef<[T]> { vec![1] }; let n = foo(); let y = n.as_ref(); let z = n.as_ref(); (n, y, z)
  4. });
  5. }
  6.  
  7.  
  8. /* ~~~~=== stderr ===~~~~
  9. Compiling playground v0.0.1 (file:///playground)
  10. error[E0277]: `impl std::convert::AsRef<[_]>` doesn't implement `std::fmt::Debug`
  11. --> src/main.rs:4:22
  12. |
  13. 4 | println!("{:?}", {
  14. | ______________________^
  15. 5 | | fn foo<T: std::fmt::Debug>() -> impl AsRef<[T]> { vec![1] }; let n = foo(); let y = n.as_ref(); let z = n.as_ref(); (n, y, z)
  16. 6 | | });
  17. | |_____^ `impl std::convert::AsRef<[_]>` cannot be formatted using `:?` because it doesn't implement `std::fmt::Debug`
  18. |
  19. = help: the trait `std::fmt::Debug` is not implemented for `impl std::convert::AsRef<[_]>`
  20. = note: required because of the requirements on the impl of `std::fmt::Debug` for `(impl std::convert::AsRef<[_]>, &[_], &[_])`
  21. = note: required by `std::fmt::Debug::fmt`
  22.  
  23. error[E0277]: the trait bound `std::vec::Vec<{integer}>: std::convert::AsRef<[T]>` is not satisfied
  24. --> src/main.rs:5:41
  25. |
  26. 5 | fn foo<T: std::fmt::Debug>() -> impl AsRef<[T]> { vec![1] }; let n = foo(); let y = n.as_ref(); let z = n.as_ref(); (n, y, z)
  27. | ^^^^^^^^^^^^^^^ the trait `std::convert::AsRef<[T]>` is not implemented for `std::vec::Vec<{integer}>`
  28. |
  29. = help: the following implementations were found:
  30. <std::vec::Vec<T> as std::convert::AsRef<[T]>>
  31. <std::vec::Vec<T> as std::convert::AsRef<std::vec::Vec<T>>>
  32. = note: the return type of a function must have a statically known size
  33.  
  34. error: aborting due to 2 previous errors
  35.  
  36. For more information about this error, try `rustc --explain E0277`.
  37. error: Could not compile `playground`.
  38.  
  39. To learn more, run the command again with --verbose.
  40.  
  41. */
  42.  
  43. /* ~~~~=== stdout ===~~~~
  44.  
  45. */
Add Comment
Please, Sign In to add comment