rust/src/test/run-pass/kindck-owned-trait-contains-1.rs

16 lines
324 B
Rust
Raw Normal View History

trait repeat<A> { fn get() -> A; }
2012-08-07 20:10:06 -05:00
impl<A:copy> @A: repeat<A> {
fn get() -> A { *self }
}
fn repeater<A:copy>(v: @A) -> repeat<A> {
// Note: owned kind is not necessary as A appears in the trait type
v as repeat::<A> // No
}
fn main() {
let x = &3;
let y = repeater(@x);
assert *x == *(y.get());
}