File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 1
1
# Variables
2
2
3
+ r[ variable]
4
+
5
+ r[ variable.intro]
3
6
A _ variable_ is a component of a stack frame, either a named function parameter,
4
7
an anonymous [ temporary] ( expressions.md#temporaries ) , or a named local
5
8
variable.
6
9
10
+ r[ variable.local]
7
11
A _ local variable_ (or * stack-local* allocation) holds a value directly,
8
12
allocated within the stack's memory. The value is a part of the stack frame.
9
13
14
+ r[ variable.local-mut]
10
15
Local variables are immutable unless declared otherwise. For example:
11
16
` let mut x = ... ` .
12
17
18
+ r[ variable.param-mut]
13
19
Function parameters are immutable unless declared with ` mut ` . The ` mut ` keyword
14
20
applies only to the following parameter. For example: ` |mut x, y| ` and
15
21
` fn f(mut x: Box<i32>, y: Box<i32>) ` declare one mutable variable ` x ` and one
16
22
immutable variable ` y ` .
17
23
24
+ r[ variable.init]
18
25
Local variables are not initialized when allocated. Instead, the entire frame
19
26
worth of local variables are allocated, on frame-entry, in an uninitialized
20
27
state. Subsequent statements within a function may or may not initialize the
You can’t perform that action at this time.
0 commit comments