Skip to content

Commit 976e1ce

Browse files
committed
test: Add a test for generic objects. r=test-only
1 parent 9e1c9be commit 976e1ce

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/run-pass/generic-object.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
trait Foo<T> {
2+
fn get() -> T;
3+
}
4+
5+
struct S {
6+
x: int
7+
}
8+
9+
impl S : Foo<int> {
10+
fn get() -> int {
11+
self.x
12+
}
13+
}
14+
15+
fn main() {
16+
let x = @S { x: 1 };
17+
let y = x as @Foo<int>;
18+
assert y.get() == 1;
19+
}
20+

0 commit comments

Comments
 (0)