How to do it...

  1. In the command line, jump one folder up with cd .. so you're not in chapter-one anymore. In the next chapters, we are going to assume that you always started with this step.
  2. Create a Rust project to work on during this chapter with cargo new chapter-two.

  3. Navigate into the newly-created chapter-two folder. For the rest of this chapter, we will assume that your command line is currently in this directory.
  4. Inside the folder src, create a new folder called bin.
  5. Delete the generated file, as we are not creating a library.
  6. In the folder src/bin, create a file called
  7. Add the following code blocks to the file and run them with cargo run --bin vector:
1  fn main() {2    // Create a vector with some elements3 let fruits ...

Get Rust Standard Library Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.