blob: 9d4254a708e2b2932df900aa410c38d2e36f31ef (
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)
}
|