rust/tests/ui/max-min-classes.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
455 B
Rust
Raw Normal View History

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