Image we have a code as given below:
trait MyTrait {
fn foo(&mut self) {
// self.0 += 1;
}
}
struct S1(usize);
impl MyTrait for S1 {}
struct S2(usize);
impl MyTrait for S2 {}
fn main() {
let mut s = S1(0);
s.foo();
let mut s = S2(0);
s.foo();
}
Is there a way to tell the compiler that the trait method foo
expects its parameter to have only one argument with the usize
type?