test: Add a test for generic objects. r=test-only
This commit is contained in:
parent
9e1c9be16f
commit
976e1ced00
20
src/test/run-pass/generic-object.rs
Normal file
20
src/test/run-pass/generic-object.rs
Normal file
@ -0,0 +1,20 @@
|
||||
trait Foo<T> {
|
||||
fn get() -> T;
|
||||
}
|
||||
|
||||
struct S {
|
||||
x: int
|
||||
}
|
||||
|
||||
impl S : Foo<int> {
|
||||
fn get() -> int {
|
||||
self.x
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = @S { x: 1 };
|
||||
let y = x as @Foo<int>;
|
||||
assert y.get() == 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user