pub struct Pattern { /* private fields */ }Expand description
A compiled Unix shell style pattern.
-
?matches any single character. -
*matches any (possibly empty) sequence of characters. -
**matches the current directory and arbitrary subdirectories. This sequence must form a single path component, so both**aandb**are invalid and will result in an error. A sequence of more than two consecutive*characters is also invalid.
Implementations§
source§impl Pattern
impl Pattern
sourcepub fn new(pattern: &str) -> Result<Self, PatternError>
pub fn new(pattern: &str) -> Result<Self, PatternError>
This function compiles Unix shell style patterns.
An invalid glob pattern will yield a PatternError.
sourcepub fn matches(&self, str: &str) -> bool
pub fn matches(&self, str: &str) -> bool
Return if the given str matches this Pattern using the default
match options (i.e. MatchOptions::new()).
Examples
use nu_glob::Pattern;
assert!(Pattern::new("c?t").unwrap().matches("cat"));
assert!(Pattern::new("d*g").unwrap().matches("doog"));sourcepub fn matches_path(&self, path: &Path) -> bool
pub fn matches_path(&self, path: &Path) -> bool
Return if the given Path, when converted to a str, matches this
Pattern using the default match options (i.e. MatchOptions::new()).
sourcepub fn matches_with(&self, str: &str, options: MatchOptions) -> bool
pub fn matches_with(&self, str: &str, options: MatchOptions) -> bool
Return if the given str matches this Pattern using the specified
match options.
sourcepub fn matches_path_with(&self, path: &Path, options: MatchOptions) -> bool
pub fn matches_path_with(&self, path: &Path, options: MatchOptions) -> bool
Return if the given Path, when converted to a str, matches this
Pattern using the specified match options.
Trait Implementations§
source§impl FromStr for Pattern
impl FromStr for Pattern
§type Err = PatternError
type Err = PatternError
source§impl Ord for Pattern
impl Ord for Pattern
source§impl PartialEq<Pattern> for Pattern
impl PartialEq<Pattern> for Pattern
source§impl PartialOrd<Pattern> for Pattern
impl PartialOrd<Pattern> for Pattern
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more