Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(unreachable_code)]
- fn main() {
- println!("{:?}", {
- use std::convert::{TryFrom, TryInto}; 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<'a, T: 'a, V: 'static + TryInto<NewType<'a, T>>>(_: V) {} let vec: Vec<i32> = Vec::new(); check(&vec)
- });
- }
- /* ~~~~=== stderr ===~~~~
- Compiling playground v0.0.1 (/playground)
- error[E0597]: `vec` does not live long enough
- --> src/main.rs:6:339
- |
- 6 | use std::convert::{TryFrom, TryInto}; 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<'a, T: 'a, V: 'static + TryInto<NewType<'a, T>>>(_: V) {} let vec: Vec<i32> = Vec::new(); check(&vec)
- | ------^^^^-
- | | |
- | | borrowed value does not live long enough
- | argument requires that `vec` is borrowed for `'static`
- 7 | });
- | - `vec` dropped here while still borrowed
- error: aborting due to previous error
- For more information about this error, try `rustc --explain E0597`.
- 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