SHARE
TWEET

Untitled

a guest Apr 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(unreachable_code)]
  2.  
  3.  
  4. fn main() {
  5.     println!("{:?}", {
  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)
  7.     });
  8. }
  9.  
  10.  
  11. /* ~~~~=== stderr ===~~~~
  12.    Compiling playground v0.0.1 (/playground)
  13. error[E0405]: cannot find trait `TryInto` in this scope
  14.  --> src/main.rs:6:235
  15.   |
  16. 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)
  17.   |                                                                                                                                                                                                                                           ^^^^^^^ not found in this scope
  18. help: possible candidates are found in other modules, you can import them into scope
  19.   |
  20. 4 | use core::convert::TryInto;
  21.   |
  22. 4 | use std::convert::TryInto;
  23.   |
  24. 4 | use try_from::TryInto;
  25.   |
  26.  
  27. error[E0637]: `'_` cannot be used here
  28.  --> src/main.rs:6:251
  29.   |
  30. 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)
  31.   |                                                                                                                                                                                                                                                           ^^ `'_` is a reserved lifetime name
  32.  
  33. error: aborting due to 2 previous errors
  34.  
  35. Some errors occurred: E0405, E0637.
  36. For more information about an error, try `rustc --explain E0405`.
  37. error: Could not compile `playground`.
  38.  
  39. To learn more, run the command again with --verbose.
  40.  
  41. */
  42.  
  43. /* ~~~~=== stdout ===~~~~
  44.  
  45. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top