From b2b2095eaf2e71b1b60797a96c097572928f001c Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Tue, 22 Oct 2013 21:37:42 -0400 Subject: [PATCH] Update the manual. --- doc/rust.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/rust.md b/doc/rust.md index fd2da43a037f..40a3bc12798f 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