Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- println!("{:?}", {
- 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)
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (file:///playground)
- error[E0277]: `impl std::convert::AsRef<[_]>` doesn't implement `std::fmt::Debug`
- --> src/main.rs:4:22
- |
- 4 | println!("{:?}", {
- | ______________________^
- 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)
- 6 | | });
- | |_____^ `impl std::convert::AsRef<[_]>` cannot be formatted using `:?` because it doesn't implement `std::fmt::Debug`
- |
- = help: the trait `std::fmt::Debug` is not implemented for `impl std::convert::AsRef<[_]>`
- = note: required because of the requirements on the impl of `std::fmt::Debug` for `(impl std::convert::AsRef<[_]>, &[_], &[_])`
- = note: required by `std::fmt::Debug::fmt`
- error[E0277]: the trait bound `std::vec::Vec<{integer}>: std::convert::AsRef<[T]>` is not satisfied
- --> src/main.rs:5:41
- |
- 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)
- | ^^^^^^^^^^^^^^^ the trait `std::convert::AsRef<[T]>` is not implemented for `std::vec::Vec<{integer}>`
- |
- = help: the following implementations were found:
- <std::vec::Vec<T> as std::convert::AsRef<[T]>>
- <std::vec::Vec<T> as std::convert::AsRef<std::vec::Vec<T>>>
- = note: the return type of a function must have a statically known size
- error: aborting due to 2 previous errors
- For more information about this error, try `rustc --explain E0277`.
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Add Comment
Please, Sign In to add comment