How to do it...

Follow the steps to implement this recipe:

  1. Open the main.rs file in the src directory in your preferred text editor.
  2. Write the code header with the relevant information:
        //-- #########################
//-- Task: glob experiments
//-- Author: Vigneshwer.D
//-- Version: 1.0.0
//-- Date: 04 May 17
//-- #########################
  1. Create the error_chain! macro to define a custom Error and Result type, along with automatic conversions from the standard library error types, after the code header:
        #[macro_use]
extern crate error_chain;
error_chain! {
foreign_links {
Glob(glob::GlobError);
Pattern(glob::PatternError);
}
}
  1. Define the run method and the quick_main! macro by copying and pasting the following code snippet with the error_chain! macro:
        extern crate glob;
use glob::glob;
fn run() -> Result<()> {
for entry in glob("**/*.png")? {
println!("{}", entry?.display());
}
Ok(())
}
quick_main!(run);
  1. Save the file and run the project by running the following command:
      cargo run

We should get the following output on execution of the code:

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

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