11# Variables
22
3- A _ variable_ is a component of a stack frame, either a named function parameter,
3+ A _ variable_ is a component of a stack frame. That component can be a named function parameter,
44an anonymous [ temporary] ( expressions.html#lvalues-rvalues-and-temporaries ) , or a named local
55variable.
66
77A _ local variable_ (or * stack-local* allocation) holds a value directly,
88allocated within the stack's memory. The value is a part of the stack frame.
99
10- Local variables are immutable unless declared otherwise like : ` let mut x = ... ` .
10+ Local variables are immutable unless declared otherwise. For example : ` let mut x = ... ` .
1111
1212Function parameters are immutable unless declared with ` mut ` . The ` mut ` keyword
13- applies only to the following parameter (so ` |mut x, y| ` and `fn f(mut x:
13+ applies only to the following parameter. For example: ` |mut x, y| ` and `fn f(mut x:
1414Box<i32 >, y: Box<i32 >)` declare one mutable variable ` x` and one immutable
15- variable ` y ` ) .
15+ variable ` y ` .
1616
1717Methods that take either ` self ` or ` Box<Self> ` can optionally place them in a
18- mutable variable by prefixing them with ` mut ` (similar to regular arguments):
18+ mutable variable by prefixing them with ` mut ` (similar to regular arguments). For example :
1919
2020``` rust
2121trait Changer : Sized {
@@ -24,8 +24,8 @@ trait Changer: Sized {
2424}
2525```
2626
27- Local variables are not initialized when allocated; the entire frame worth of
28- local variables are allocated at once , on frame-entry, in an uninitialized
27+ Local variables are not initialized when allocated. Instead, the entire frame worth of
28+ local variables are allocated, on frame-entry, in an uninitialized
2929state. Subsequent statements within a function may or may not initialize the
3030local variables. Local variables can be used only after they have been
3131initialized; this is enforced by the compiler.
0 commit comments