1extern crate glob;
6
7use std::path::Path;
8
9use glob::{glob_with,Paths,PatternError,MatchOptions};
10
11pub trait Glob {
15 fn glob_with(&self, pattern: &str, options: &MatchOptions) -> Result<Paths, PatternError>;
17
18 fn glob(&self, pattern: &str) -> Result<Paths, PatternError> {
20 self.glob_with(pattern, &MatchOptions::new())
21 }
22
23 fn rglob_with(&self, pattern: &str, options: &MatchOptions) -> Result<Paths, PatternError> {
25 self.glob_with(&format!("**/{}", pattern), options)
26 }
27
28 fn rglob(&self, pattern: &str) -> Result<Paths, PatternError> {
30 self.rglob_with(pattern, &MatchOptions::new())
31 }
32}
33
34impl<P: AsRef<Path>> Glob for P {
35 fn glob_with(&self, pattern: &str, options: &MatchOptions) -> Result<Paths, PatternError> {
36 glob_with(self.as_ref().join(pattern).to_str().unwrap(), options)
37 }
38}