about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-03-29 15:07:36 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-03-29 15:45:10 -0400
commitf78af18127e2bc0075479e8495bfa63807e938fc (patch)
tree8b0bcf2b94ecab7582ced7200fdf8bed42af0fe3
parent85ed840e234184b7975d9ee7b022c0ca2cb5d8ff (diff)
downloadrust-f78af18127e2bc0075479e8495bfa63807e938fc.tar.gz
rust-f78af18127e2bc0075479e8495bfa63807e938fc.zip
tutorial: improve the managed boxes section
-rw-r--r--doc/tutorial.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/tutorial.md b/doc/tutorial.md
index 009c1054737..fbeda4257f5 100644
--- a/doc/tutorial.md
+++ b/doc/tutorial.md
@@ -1053,6 +1053,20 @@ mutability. They do own the contained object, and mutability is defined by the
 type of the shared box (`@` or `@mut`). An object containing a managed box is
 not `Owned`, and can't be sent between tasks.
 
+~~~~
+let a = @5; // immutable
+
+let mut b = @5; // mutable variable, immutable box
+b = @10;
+
+let c = @mut 5; // immutable variable, mutable box
+*c = 10;
+
+let mut d = @mut 5; // mutable variable, mutable box
+*d += 5;
+d = @mut 15;
+~~~~
+
 # Move semantics
 
 Rust uses a shallow copy for parameter passing, assignment and returning values