]> git.lizzy.rs Git - rust.git/blob - tests/ui/associated-types/associated-types-constant-type.rs
Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum
[rust.git] / tests / ui / associated-types / associated-types-constant-type.rs
1 // run-pass
2
3 trait SignedUnsigned {
4     type Opposite;
5     fn convert(self) -> Self::Opposite;
6 }
7
8 impl SignedUnsigned for isize {
9     type Opposite = usize;
10
11     fn convert(self) -> usize {
12         self as usize
13     }
14 }
15
16 impl SignedUnsigned for usize {
17     type Opposite = isize;
18
19     fn convert(self) -> isize {
20         self as isize
21     }
22 }
23
24 fn get(x: isize) -> <isize as SignedUnsigned>::Opposite {
25     x.convert()
26 }
27
28 fn main() {
29     let x = get(22);
30     assert_eq!(22, x);
31 }