blob: 487860c01b1f5f7cbf1bed2da41ea12d4351f202 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
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.
let h: @int = r(); //~ ERROR (values differ in mutability)
}
|