Skip to content

Commit

Permalink
Update the manual.
Browse files Browse the repository at this point in the history
  • Loading branch information
luqmana committed Oct 23, 2013
1 parent 03111fb commit b2b2095
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

5 comments on commit b2b2095

@bors
Copy link
Contributor

@bors bors commented on b2b2095 Oct 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at luqmana@b2b2095

@bors
Copy link
Contributor

@bors bors commented on b2b2095 Oct 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging luqmana/rust/mut-everywhere = b2b2095 into auto

@bors
Copy link
Contributor

@bors bors commented on b2b2095 Oct 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

luqmana/rust/mut-everywhere = b2b2095 merged ok, testing candidate = 7857314

@bors
Copy link
Contributor

@bors bors commented on b2b2095 Oct 23, 2013

@bors
Copy link
Contributor

@bors bors commented on b2b2095 Oct 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 7857314

Please sign in to comment.