February 2022
Intermediate to advanced
140 pages
2h 28m
English
| Puzzle 17 | How Long Is a Vector? |
| | fn main() { |
| | let mut my_vec = Vec::with_capacity(1); |
| | my_vec.push("Hello"); |
| | println!("{}", my_vec.capacity()); |
| | my_vec.push("World"); |
| | println!("{}", my_vec.capacity()); |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
The program will display the following output:
| | 1 |
| | 4 |
Vectors contain two things: a length indicating ...
Read now
Unlock full access