f6491bb426
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
15 lines
260 B
Rust
15 lines
260 B
Rust
fn double<copy T>(a: T) -> [T] { ret [a] + [a]; }
|
|
|
|
fn double_int(a: int) -> [int] { ret [a] + [a]; }
|
|
|
|
fn main() {
|
|
let d = double(1);
|
|
assert (d[0] == 1);
|
|
assert (d[1] == 1);
|
|
|
|
d = double_int(1);
|
|
assert (d[0] == 1);
|
|
assert (d[1] == 1);
|
|
}
|
|
|