Skip to content

Commit a37873d

Browse files
committed
add a coretest checking TryInto/TryFrom impls
1 parent e645e51 commit a37873d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

library/coretests/tests/convert.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,20 @@ fn convert() {
1414
const BAR: Vec<String> = into(Vec::new());
1515
assert_eq!(BAR, Vec::<String>::new());
1616
}
17+
18+
#[test]
19+
fn into_as_try_into() {
20+
struct A;
21+
struct B;
22+
23+
impl Into<B> for A {
24+
fn into(self) -> B {
25+
B
26+
}
27+
}
28+
29+
// This wouldn't compile if the `TryInto`/`TryFrom` blanket impls used
30+
// `U: From<T>` instead of `T: Into<U>`
31+
let Ok(B) = A.try_into();
32+
let Ok(B) = B::try_from(A);
33+
}

0 commit comments

Comments
 (0)