about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2011-11-16 12:32:38 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2011-11-18 12:49:00 +0100
commit4e0311214160ea0dc7d1ff7347db6c6550c79de2 (patch)
treec4024b2ab58c93b1441e887e0f3e93936d2dc530 /src/test
parent6297fc979ee715c276b5303decf2220e70629917 (diff)
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
Diffstat (limited to 'src/test')
-rw-r--r--src/test/run-pass/pass-by-copy.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/test/run-pass/pass-by-copy.rs b/src/test/run-pass/pass-by-copy.rs
new file mode 100644
index 00000000000..61cdd01ba21
--- /dev/null
+++ b/src/test/run-pass/pass-by-copy.rs
@@ -0,0 +1,8 @@
+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);
+}