rust/src/test/run-pass/uniq-cc-generic.rs

27 lines
397 B
Rust
Raw Normal View History

enum maybe_pointy {
none,
p(@pointy),
}
type pointy = {
2012-03-26 20:35:18 -05:00
mut a : maybe_pointy,
d : fn~() -> uint,
};
fn make_uniq_closure<A:Send Copy>(a: A) -> fn~() -> uint {
fn~() -> uint { ptr::addr_of(a) as uint }
}
fn empty_pointy() -> @pointy {
2012-08-01 19:30:05 -05:00
return @{
2012-03-26 20:35:18 -05:00
mut a : none,
d : make_uniq_closure(~"hi")
}
}
fn main()
{
let v = empty_pointy();
v.a = p(v);
}