2012-07-31 10:27:51 -07:00
|
|
|
trait repeat<A> { fn get() -> A; }
|
2012-07-18 11:01:54 -07:00
|
|
|
|
2012-09-07 14:52:28 -07:00
|
|
|
impl<A:Copy> @A: repeat<A> {
|
2012-07-18 11:01:54 -07:00
|
|
|
fn get() -> A { *self }
|
|
|
|
}
|
|
|
|
|
2012-09-07 14:52:28 -07:00
|
|
|
fn repeater<A:Copy>(v: @A) -> repeat<A> {
|
2012-07-31 10:27:51 -07:00
|
|
|
// Note: owned kind is not necessary as A appears in the trait type
|
2012-07-18 11:01:54 -07:00
|
|
|
v as repeat::<A> // No
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Here, an error results as the type of y is inferred to
|
|
|
|
// repeater<</3> where lt is the block.
|
2012-08-13 15:06:13 -07:00
|
|
|
let y = {
|
|
|
|
let x: &blk/int = &3; //~ ERROR cannot infer an appropriate lifetime
|
2012-07-18 11:01:54 -07:00
|
|
|
repeater(@x)
|
|
|
|
};
|
2012-08-13 15:06:13 -07:00
|
|
|
assert 3 == *(y.get());
|
2012-07-18 11:01:54 -07:00
|
|
|
}
|