How to do it...

  1. Open the Cargo.toml file in your favorite text editor; in this recipe, we will use the nano editor:
      nano Cargo.toml

You should get the following output:

  1. Add a [dependencies] section to the cargo.toml file and enter time = "0.1.12" and regex = "0.1.41" below it.

You should get the following output:

  1. Use the cat command to see the configuration list:
      cat Cargo.toml

You should get the following output:

  1. Build the project to pull the dependencies from https://crates.io/:
      cargo build

You should get the following output:

  1. Use the existing crates pulled in our project.

Open the main.rs file in the src directory using nano and enter the following code:

      nano main.rs

You should get the following output:

        // Declare the external crate
extern
crate regex;
use regex::Regex;
fn main() {
let check_date = Regex::new(r"^d{4}-d{2}-d{2}$").unwrap();
println!("Did our date match? {}", check_date.is_match("2017
-02-01"
));
}

You should get the following state output:

  1. Compile and run the project:
      cargo run 

You should get the following output:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.220.92