rust/src/test/run-pass/pass-by-copy.rs
Marijn Haverbeke 4e03112141 Add a pass-by-copy parameter passing convention
This is intended to solve the problem of how to pass arguments to
constructor functions -- you want to move in rvalues, but not have to
explicitly copy stuff that is not an rvalue. The by-copy passing
convention will ensure the callee gets its own copy of the value. For
rvalues, it'll just pass off the value. For lvalues, it'll make a
copy.

Issue #1177
2011-11-18 12:49:00 +01:00

9 lines
171 B
Rust

fn magic(+x: {a: @int}) { log x; }
fn magic2(+x: @int) { log x; }
fn main() {
let a = {a: @10}, b = @10;
magic(a); magic({a: @20});
magic2(b); magic2(@20);
}