Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unreachable_code)]
- fn main() {
- println!("{:?}", {
- use std::convert::TryFrom; struct NewType<'a, T>(&'a Vec<T>); impl<'a, T> TryFrom<&'a Vec<T>> for NewType<'a, T> { type Error = (); fn try_from(vec: &'a Vec<T>) -> Result<NewType<'a, T>, ()> { Ok(NewType(vec)) } } fn check<T: TryInto<NewType<'_, T>>>(_: T) {} let vec: Vec<i32> = Vec::new(); check(&vec)
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (/playground)
- error[E0405]: cannot find trait `TryInto` in this scope
- --> src/main.rs:6:235
- |
- 6 | use std::convert::TryFrom; struct NewType<'a, T>(&'a Vec<T>); impl<'a, T> TryFrom<&'a Vec<T>> for NewType<'a, T> { type Error = (); fn try_from(vec: &'a Vec<T>) -> Result<NewType<'a, T>, ()> { Ok(NewType(vec)) } } fn check<T: TryInto<NewType<'_, T>>>(_: T) {} let vec: Vec<i32> = Vec::new(); check(&vec)
- | ^^^^^^^ not found in this scope
- help: possible candidates are found in other modules, you can import them into scope
- |
- 4 | use core::convert::TryInto;
- |
- 4 | use std::convert::TryInto;
- |
- 4 | use try_from::TryInto;
- |
- error[E0637]: `'_` cannot be used here
- --> src/main.rs:6:251
- |
- 6 | use std::convert::TryFrom; struct NewType<'a, T>(&'a Vec<T>); impl<'a, T> TryFrom<&'a Vec<T>> for NewType<'a, T> { type Error = (); fn try_from(vec: &'a Vec<T>) -> Result<NewType<'a, T>, ()> { Ok(NewType(vec)) } } fn check<T: TryInto<NewType<'_, T>>>(_: T) {} let vec: Vec<i32> = Vec::new(); check(&vec)
- | ^^ `'_` is a reserved lifetime name
- error: aborting due to 2 previous errors
- Some errors occurred: E0405, E0637.
- For more information about an error, try `rustc --explain E0405`.
- error: Could not compile `playground`.
- To learn more, run the command again with --verbose.
- */
- /* ~~~~=== stdout ===~~~~
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement