mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Minor formatting and wording change in rust doc. (#2277)
This commit is contained in:
parent
273fa8606b
commit
a7015a0f85
@ -281,7 +281,7 @@ fn main() {
|
|||||||
println!("{}", var); // Unlike `box`, `var` can still be used
|
println!("{}", var); // Unlike `box`, `var` can still be used
|
||||||
println!("{}", *ref_var);
|
println!("{}", *ref_var);
|
||||||
// var = 5; // this would not compile because `var` is borrowed
|
// var = 5; // this would not compile because `var` is borrowed
|
||||||
// *ref_var = 6; // this would not too, because `ref_var` is an immutable reference
|
// *ref_var = 6; // this would not either, because `ref_var` is an immutable reference
|
||||||
|
|
||||||
// Mutable reference
|
// Mutable reference
|
||||||
// While a value is mutably borrowed, it cannot be accessed at all.
|
// While a value is mutably borrowed, it cannot be accessed at all.
|
||||||
@ -289,8 +289,9 @@ fn main() {
|
|||||||
let ref_var2: &mut i32 = &mut var2;
|
let ref_var2: &mut i32 = &mut var2;
|
||||||
*ref_var2 += 2; // '*' is used to point to the mutably borrowed var2
|
*ref_var2 += 2; // '*' is used to point to the mutably borrowed var2
|
||||||
|
|
||||||
println!("{}", *ref_var2); // 6 , //var2 would not compile. //ref_var2 is of type &mut i32, so //stores a reference to an i32 not the value.
|
println!("{}", *ref_var2); // 6 , // var2 would not compile.
|
||||||
// var2 = 2; // this would not compile because `var2` is borrowed
|
// ref_var2 is of type &mut i32, so stores a reference to an i32, not the value.
|
||||||
|
// var2 = 2; // this would not compile because `var2` is borrowed.
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user