home ~ projects ~ socials

Do A Case Insensitive glob Director Search In Rust

//! ```cargo
//! [dependencies]
//! glob = "0.3.1"
//! ```

use glob::glob_with;
use glob::MatchOptions;

fn main() {
  let options = MatchOptions {
      case_sensitive: false,
      require_literal_separator: false,
      require_literal_leading_dot: false,
  };
  for entry in glob_with("glob_test/*o*", options).unwrap() {
      if let Ok(path) = entry {
          println!("{:?}", path.display())
      }
  }
}
Output:
"glob_test/BRAVO.txt"
"glob_test/echo.txt"
"glob_test/fOxtrOt.txt"
"glob_test/golf.txt"
"glob_test/hotel.txt"

Notes

  • This example is stright from >the rust docs>https://docs.rs/glob/latest/glob/>
  • I haven't looked up the separator and leading_dot options yet
-- end of line --