We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 728d16c commit 22ef082Copy full SHA for 22ef082
src/test/run-pass/max-min-classes.rs
@@ -0,0 +1,30 @@
1
+trait Product {
2
+ fn product() -> int;
3
+}
4
+
5
+struct Foo {
6
+ x: int;
7
+ y: int;
8
9
10
+impl Foo {
11
+ fn sum() -> int {
12
+ self.x + self.y
13
+ }
14
15
16
+impl Foo : Product {
17
+ fn product() -> int {
18
+ self.x * self.y
19
20
21
22
+fn Foo(x: int, y: int) -> Foo {
23
+ Foo { x: x, y: y }
24
25
26
+fn main() {
27
+ let foo = Foo(3, 20);
28
+ io::println(#fmt("%d %d", foo.sum(), foo.product()));
29
30
0 commit comments