- Create a Rust project to work on during this chapter with cargo new chapter_four.
- Navigate into the newly-created chapter_four folder. For the rest of this chapter, we will assume that your command line is currently in this directory.
- Inside the src folder, create a new folder called bin.
- Delete the generated lib.rs file, as we are not creating a library.
-
Open the Cargo.toml file that was generated earlier for you.
- Under [dependencies], add the following line:
csv = "1.0.0-beta.5"
- If you want, you can go to csv's crates.io page (https://crates.io/crates/csv) to check for the newest version and use that one instead.
- In the src/bin folder, create a file called csv.rs
- Add the following code and run it with cargo run --bin csv:
1 extern crate csv;
2
3 use std::io::{BufReader, BufWriter, Read, Seek, SeekFrom,
Write};
4 use std::fs::OpenOptions;
5
6 fn main() {
7 let file = OpenOptions::new()
8 .read(true)
9 ...