aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/impl_trait1.rs
blob: 33a5c8cf1dbbfde5cb48088950f094174ed5182e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#[lang = "sized"]
trait Sized {}

pub trait Value {
    fn get(&self) -> i32;
}

struct Foo(i32);
struct Bar(i32);

impl Value for Foo {
    fn get(&self) -> i32 {
        self.0
    }
}
impl Value for Bar {
    fn get(&self) -> i32 {
        self.0
    }
}

pub fn foo(a: impl Value, b: impl Value) -> i32 {
    a.get() + b.get()
}

fn main() -> i32 {
    let a = Foo(1);
    let b = Bar(2);

    foo(a, b) - 3
}