pub struct Pattern { /* private fields */ }Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn is_more_specific_than(&self, other: &Self) -> bool
pub fn is_more_specific_than(&self, other: &Self) -> bool
self is weakly more specific than other.
If self and other are not comparable, then this method
returns false both ways. If self and other are the same,
then it returns true both ways.
§Examples
TODO
Sourcepub fn count_matching_chars(&self, path: &str) -> Option<usize>
pub fn count_matching_chars(&self, path: &str) -> Option<usize>
Counts the number of characters in path that are either
- matched exactly (e.g.,
a), - matched by a character class (e.g.,
[a-f]), or - matched by a single-character wildcard (
?)
This means that it does not count characters that are matched by
* or **.
Returns None if the pattern does not match path.
§Examples
use std::str::FromStr;
use globcmp_lib::Pattern;
let pattern = Pattern::from_str("foo/bar").unwrap();
let count = pattern.count_matching_chars("foo/bar");
assert_eq!(count, Some(7));use std::str::FromStr;
use globcmp_lib::Pattern;
let pattern = Pattern::from_str("foo/*r").unwrap();
let count = pattern.count_matching_chars("foo/bar");
assert_eq!(count, Some(5));use std::str::FromStr;
use globcmp_lib::Pattern;
let pattern = Pattern::from_str("foo/*z").unwrap();
let count = pattern.count_matching_chars("foo/bar");
assert!(count.is_none());Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the string representation with which
Pattern::from_str was called.
Trait Implementations§
impl Eq for Pattern
impl StructuralPartialEq for Pattern
Auto Trait Implementations§
impl Freeze for Pattern
impl RefUnwindSafe for Pattern
impl Send for Pattern
impl Sync for Pattern
impl Unpin for Pattern
impl UnwindSafe for Pattern
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more