This involved adding 'copy' to more generics than I hoped, but an experiment with making it implicit showed that that way lies madness -- unless enforced, you will not remember to mark functions that don't copy as not requiring copyable kind. Issue #1177
8 lines
184 B
Rust
8 lines
184 B
Rust
|
|
|
|
fn box<copy T>(x: {x: T, y: T, z: T}) -> @{x: T, y: T, z: T} { ret @x; }
|
|
|
|
fn main() {
|
|
let x: @{x: int, y: int, z: int} = box::<int>({x: 1, y: 2, z: 3});
|
|
assert (x.y == 2);
|
|
}
|