rust/src/test/run-pass/max-min-classes.rs

31 lines
442 B
Rust
Raw Normal View History

#![allow(non_snake_case)]
2012-07-24 23:39:26 +00:00
trait Product {
fn product(&self) -> isize;
2012-07-24 23:39:26 +00:00
}
struct Foo {
x: isize,
y: isize,
2012-07-24 23:39:26 +00:00
}
impl Foo {
pub fn sum(&self) -> isize {
2012-07-24 23:39:26 +00:00
self.x + self.y
}
}
impl Product for Foo {
fn product(&self) -> isize {
2012-07-24 23:39:26 +00:00
self.x * self.y
}
}
fn Foo(x: isize, y: isize) -> Foo {
2012-07-24 23:39:26 +00:00
Foo { x: x, y: y }
}
pub fn main() {
2012-07-24 23:39:26 +00:00
let foo = Foo(3, 20);
println!("{} {}", foo.sum(), foo.product());
2012-07-24 23:39:26 +00:00
}