blob: 3d7c2eb084c5b322b40be4b90ef8a4c857ac549d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
trait TraitA {
fn method_a(&self) -> isize;
}
trait TraitB {
fn gimme_an_a<A:TraitA>(&self, a: A) -> isize;
}
impl TraitB for isize {
fn gimme_an_a<A:TraitA>(&self, a: A) -> isize {
a.method_a() + *self
}
}
fn call_it<B:TraitB>(b: B) -> isize {
let y = 4;
b.gimme_an_a(y) //~ ERROR `{integer}: TraitA` is not satisfied
}
fn main() {
let x = 3;
assert_eq!(call_it(x), 22);
}
|