File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 11# Variables
22
3+ r[ variable]
4+
5+ r[ variable.intro]
36A _ variable_ is a component of a stack frame, either a named function parameter,
47an anonymous [ temporary] ( expressions.md#temporaries ) , or a named local
58variable.
69
10+ r[ variable.local]
711A _ local variable_ (or * stack-local* allocation) holds a value directly,
812allocated within the stack's memory. The value is a part of the stack frame.
913
14+ r[ variable.local-mut]
1015Local variables are immutable unless declared otherwise. For example:
1116` let mut x = ... ` .
1217
18+ r[ variable.param-mut]
1319Function parameters are immutable unless declared with ` mut ` . The ` mut ` keyword
1420applies only to the following parameter. For example: ` |mut x, y| ` and
1521` fn f(mut x: Box<i32>, y: Box<i32>) ` declare one mutable variable ` x ` and one
1622immutable variable ` y ` .
1723
24+ r[ variable.init]
1825Local variables are not initialized when allocated. Instead, the entire frame
1926worth of local variables are allocated, on frame-entry, in an uninitialized
2027state. Subsequent statements within a function may or may not initialize the
You can’t perform that action at this time.
0 commit comments