Debian Codegraph @

gcc/testsuite/rust/compile/torture/traits9.rs

raw
1 #[lang = "sized"]
2 pub trait Sized {}
3
4 trait Foo {
5 fn default() -> i32;
6 fn get(self) -> i32;
7 }
8
9 struct Bar(i32);
10 impl Foo for Bar {
11 fn default() -> i32 {
12 123
13 }
14
15 fn get(self) -> i32 {
16 self.0
17 }
18 }
19
20 fn type_bound_test<T: Foo>(a: T) -> i32 {
21 T::default() + a.get()
22 }
23
24 fn main() {
25 let a;
26 a = Bar(456);
27
28 let b;
29 b = type_bound_test(a);
30 }