Made v2 mutable so that we can actually truncate it.
This commit is contained in:
parent
37a952a672
commit
1536195ce6
1 changed files with 2 additions and 2 deletions
|
|
@ -139,7 +139,7 @@ Now consider the following code fragment:
|
|||
```rust
|
||||
let v = vec![1, 2, 3];
|
||||
|
||||
let v2 = v;
|
||||
let mut v2 = v;
|
||||
```
|
||||
|
||||
The first line allocates memory for the vector object `v` on the stack like
|
||||
|
|
@ -167,7 +167,7 @@ For example if we truncated the vector to just two elements through `v2`:
|
|||
|
||||
```rust
|
||||
# let v = vec![1, 2, 3];
|
||||
# let v2 = v;
|
||||
# let mut v2 = v;
|
||||
v2.truncate(2);
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue