1 // This test relies on `TryFrom` being blanket impl for all `T: Into`
2 // and `TryInto` being blanket impl for all `U: TryFrom`
4 // This test was added to show the motivation for doing this
5 // over `TryFrom` being blanket impl for all `T: From`
7 #![feature(never_type)]
9 use std::convert::{TryInto, Infallible};
15 // This fails to compile due to coherence restrictions
16 // as of Rust version 1.32.x, therefore it could not be used
17 // instead of the `Into` version of the impl, and serves as
18 // motivation for a blanket impl for all `T: Into`, instead
19 // of a blanket impl for all `T: From`
21 impl<T> From<Foo<T>> for Box<T> {
22 fn from(foo: Foo<T>) -> Box<T> {
28 impl<T> Into<Vec<T>> for Foo<T> {
29 fn into(self) -> Vec<T> {
35 let _: Result<Vec<i32>, Infallible> = Foo { t: 10 }.try_into();