diff options
| author | Luqman Aden <laden@csclub.uwaterloo.ca> | 2013-10-22 21:37:42 -0400 |
|---|---|---|
| committer | Luqman Aden <laden@csclub.uwaterloo.ca> | 2013-10-22 21:37:42 -0400 |
| commit | b2b2095eaf2e71b1b60797a96c097572928f001c (patch) | |
| tree | eb8c74945054822c9c9b4afea428ebd2970561a9 | |
| parent | 03111fb83b8c8c2c04939dfebb2fd3b9053aa462 (diff) | |
| download | rust-b2b2095eaf2e71b1b60797a96c097572928f001c.tar.gz rust-b2b2095eaf2e71b1b60797a96c097572928f001c.zip | |
Update the manual.
| -rw-r--r-- | doc/rust.md | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/doc/rust.md b/doc/rust.md index fd2da43a037..40a3bc12798 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -3395,16 +3395,23 @@ a [temporary](#lvalues-rvalues-and-temporaries), or a local variable. A _local variable_ (or *stack-local* allocation) holds a value directly, allocated within the stack's memory. The value is a part of the stack frame. -Local variables are immutable unless declared with `let mut`. The -`mut` keyword applies to all local variables declared within that -declaration (so `let mut (x, y) = ...` declares two mutable variables, `x` and -`y`). +Local variables are immutable unless declared otherwise like: `let mut x = ...`. Function parameters are immutable unless declared with `mut`. The `mut` keyword applies only to the following parameter (so `|mut x, y|` and `fn f(mut x: ~int, y: ~int)` declare one mutable variable `x` and one immutable variable `y`). +Methods that take either `self` or `~self` can optionally place them in a +mutable slot by prefixing them with `mut` (similar to regular arguments): + +~~~ +trait Changer { + fn change(mut self) -> Self; + fn modify(mut ~self) -> ~Self; +} +~~~ + Local variables are not initialized when allocated; the entire frame worth of local variables are allocated at once, on frame-entry, in an uninitialized state. Subsequent statements within a function may or may not initialize the |
