summaryrefslogtreecommitdiffstats
path: root/src/test/ui/max-min-classes.rs
blob: f9a39e486da2ef8d6e64426c9e50831d295183b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// run-pass

#![allow(non_snake_case)]
trait Product {
    fn product(&self) -> isize;
}

struct Foo {
    x: isize,
    y: isize,
}

impl Foo {
    pub fn sum(&self) -> isize {
        self.x + self.y
    }
}

impl Product for Foo {
    fn product(&self) -> isize {
        self.x * self.y
    }
}

fn Foo(x: isize, y: isize) -> Foo {
    Foo { x: x, y: y }
}

pub fn main() {
    let foo = Foo(3, 20);
    println!("{} {}", foo.sum(), foo.product());
}