// except according to those terms.
trait Product {
- fn product() -> int;
+ fn product(&self) -> int;
}
struct Foo {
}
impl Foo {
- fn sum() -> int {
+ pub fn sum(&self) -> int {
self.x + self.y
}
}
impl Product for Foo {
- fn product() -> int {
+ fn product(&self) -> int {
self.x * self.y
}
}
pub fn main() {
let foo = Foo(3, 20);
- io::println(fmt!("%d %d", foo.sum(), foo.product()));
+ println!("{} {}", foo.sum(), foo.product());
}
-