Skip to content

Commit 83c4b5d

Browse files
committed
---
yaml --- r: 12470 b: refs/heads/master c: 658b6a7 h: refs/heads/master v: v3
1 parent 3d4a75c commit 83c4b5d

File tree

6 files changed

+75
-1
lines changed

6 files changed

+75
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 611061b6c31ec7f96025b07cee53cfb7fe8ee3d9
2+
refs/heads/master: 658b6a741b7d2bd01c7e14211b4299f12c0a3ebf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
type T = cat;
2+
3+
enum cat {
4+
howlycat,
5+
meowlycat
6+
}
7+
8+
fn animal() -> str { "cat" }
9+
fn talk(c: cat) -> str {
10+
alt c {
11+
howlycat { "howl" }
12+
meowlycat { "meow" }
13+
}
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
type T = dog;
2+
3+
enum dog {
4+
dog
5+
}
6+
7+
fn animal() -> str { "dog" }
8+
fn talk(_d: dog) -> str { "woof" }
9+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
impl talky for T {
2+
3+
// 'animal' and 'talk' functions are implemented by the module
4+
// instantiating the talky trait. They are 'abstract'
5+
fn says() -> str {
6+
animal() + " says '" + talk(self) + "'"
7+
}
8+
9+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#[no_core];
2+
3+
4+
#[path = "module-polymorphism4-files"]
5+
mod cat {
6+
7+
import inst::*;
8+
9+
#[path = "cat.rs"]
10+
mod inst;
11+
12+
#[path = "trait.rs"]
13+
mod trait;
14+
15+
}
16+
17+
#[path = "module-polymorphism4-files"]
18+
mod dog {
19+
20+
import inst::*;
21+
22+
#[path = "dog.rs"]
23+
mod inst;
24+
25+
#[path = "trait.rs"]
26+
mod trait;
27+
28+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This isn't really xfailed; it's used by the
2+
// module-polymorphism.rc test
3+
// xfail-test
4+
5+
fn main() {
6+
import cat::trait::talky;
7+
import dog::trait::talky;
8+
let cat1 = cat::inst::meowlycat;
9+
let cat2 = cat::inst::howlycat;
10+
let dog = dog::inst::dog;
11+
assert cat1.says() == "cat says 'meow'";
12+
assert cat2.says() == "cat says 'howl'";
13+
assert dog.says() == "dog says 'woof'";
14+
}

0 commit comments

Comments
 (0)