File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9
- refs/heads/dist-snap: 03111fb83b8c8c2c04939dfebb2fd3b9053aa462
9
+ refs/heads/dist-snap: b2b2095eaf2e71b1b60797a96c097572928f001c
10
10
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
11
11
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
12
12
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
Original file line number Diff line number Diff line change @@ -3395,16 +3395,23 @@ a [temporary](#lvalues-rvalues-and-temporaries), or a local variable.
3395
3395
A _ local variable_ (or * stack-local* allocation) holds a value directly,
3396
3396
allocated within the stack's memory. The value is a part of the stack frame.
3397
3397
3398
- Local variables are immutable unless declared with ` let mut ` . The
3399
- ` mut ` keyword applies to all local variables declared within that
3400
- declaration (so ` let mut (x, y) = ... ` declares two mutable variables, ` x ` and
3401
- ` y ` ).
3398
+ Local variables are immutable unless declared otherwise like: ` let mut x = ... ` .
3402
3399
3403
3400
Function parameters are immutable unless declared with ` mut ` . The
3404
3401
` mut ` keyword applies only to the following parameter (so ` |mut x, y| `
3405
3402
and ` fn f(mut x: ~int, y: ~int) ` declare one mutable variable ` x ` and
3406
3403
one immutable variable ` y ` ).
3407
3404
3405
+ Methods that take either ` self ` or ` ~self ` can optionally place them in a
3406
+ mutable slot by prefixing them with ` mut ` (similar to regular arguments):
3407
+
3408
+ ~~~
3409
+ trait Changer {
3410
+ fn change(mut self) -> Self;
3411
+ fn modify(mut ~self) -> ~Self;
3412
+ }
3413
+ ~~~
3414
+
3408
3415
Local variables are not initialized when allocated; the entire frame worth of
3409
3416
local variables are allocated at once, on frame-entry, in an uninitialized
3410
3417
state. Subsequent statements within a function may or may not initialize the
You can’t perform that action at this time.
0 commit comments