2012-07-31 12:27:51 -05:00
|
|
|
trait repeat<A> { fn get() -> A; }
|
2012-07-18 13:01:54 -05:00
|
|
|
|
|
|
|
impl<A:copy> of repeat<A> for @A {
|
|
|
|
fn get() -> A { *self }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn repeater<A:copy>(v: @A) -> repeat<A> {
|
2012-07-31 12:27:51 -05:00
|
|
|
// Note: owned kind is not necessary as A appears in the trait type
|
2012-07-18 13:01:54 -05:00
|
|
|
v as repeat::<A> // No
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let x = &3;
|
|
|
|
let y = repeater(@x);
|
|
|
|
assert *x == *(y.get());
|
|
|
|
}
|