// except according to those terms.
trait TraitA {
- fn method_a() -> int;
+ fn method_a(&self) -> int;
}
trait TraitB {
- fn gimme_an_a<A:TraitA>(a: A) -> int;
+ fn gimme_an_a<A:TraitA>(&self, a: A) -> int;
}
impl TraitB for int {
- fn gimme_an_a<A:TraitA>(a: A) -> int {
- a.method_a() + self
+ fn gimme_an_a<A:TraitA>(&self, a: A) -> int {
+ a.method_a() + *self
}
}
fn call_it<B:TraitB>(b: B) -> int {
let y = 4u;
- b.gimme_an_a(y) //~ ERROR failed to find an implementation of trait @TraitA
+ b.gimme_an_a(y) //~ ERROR the trait `TraitA` is not implemented
}
fn main() {
let x = 3i;
- assert call_it(x) == 22;
+ assert_eq!(call_it(x), 22);
}