2012-03-24 23:24:47 -05:00
|
|
|
fn reproduce<T:copy>(t: T) -> fn@() -> T {
|
|
|
|
fn@() -> T { t }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// type of x is the variable X,
|
|
|
|
// with the lower bound @mut int
|
|
|
|
let x = @mut 3;
|
|
|
|
|
|
|
|
// type of r is fn@() -> X
|
|
|
|
let r = reproduce(x);
|
|
|
|
|
|
|
|
// Requires that X be a subtype of
|
|
|
|
// @mut int.
|
|
|
|
let f: @mut int = r();
|
|
|
|
|
|
|
|
// OK.
|
|
|
|
let g: @const int = r();
|
|
|
|
|
|
|
|
// Bad.
|
2012-06-30 06:23:59 -05:00
|
|
|
let h: @int = r(); //~ ERROR (values differ in mutability)
|
2012-03-24 23:24:47 -05:00
|
|
|
}
|