pub struct Pattern {
pub text: BString,
pub mode: Mode,
pub first_wildcard_pos: Option<usize>,
}excludes only.Expand description
A glob pattern optimized for matching paths relative to a root directory.
For normal globbing, use wildmatch() instead.
Fields§
§text: BStringthe actual pattern bytes
mode: ModeAdditional information to help accelerate pattern matching.
first_wildcard_pos: Option<usize>The position in text with the first wildcard character, or None if there is no wildcard at all.
Implementations§
Source§impl Pattern
Instantiation
impl Pattern
Instantiation
Sourcepub fn from_bytes(text: &[u8]) -> Option<Pattern>
Available on crate feature attributes only.
pub fn from_bytes(text: &[u8]) -> Option<Pattern>
attributes only.Parse the given text as pattern, or return None if text was empty.
Sourcepub fn from_bytes_without_negation(text: &[u8]) -> Option<Pattern>
Available on crate feature attributes only.
pub fn from_bytes_without_negation(text: &[u8]) -> Option<Pattern>
attributes only.Parse the given text as pattern without supporting leading ! or \\! , or return None if text was empty.
This assures that text remains entirely unaltered, but removes built-in support for negation as well.
Source§impl Pattern
Access
impl Pattern
Access
Sourcepub fn is_negative(&self) -> bool
Available on crate feature attributes only.
pub fn is_negative(&self) -> bool
attributes only.Return true if a match is negated.
Sourcepub fn matches_repo_relative_path(
&self,
path: &BStr,
basename_start_pos: Option<usize>,
is_dir: Option<bool>,
case: Case,
mode: Mode,
) -> bool
Available on crate feature attributes only.
pub fn matches_repo_relative_path( &self, path: &BStr, basename_start_pos: Option<usize>, is_dir: Option<bool>, case: Case, mode: Mode, ) -> bool
attributes only.Match the given path which takes slashes (and only slashes) literally, and is relative to the repository root.
Note that path is assumed to be relative to the repository.
We may take various shortcuts which is when basename_start_pos and is_dir come into play.
basename_start_pos is the index at which the path’s basename starts.
case folding can be configured as well.
mode is used to control how crate::wildmatch() should operate.
Sourcepub fn matches(&self, value: &BStr, mode: Mode) -> bool
Available on crate feature attributes only.
pub fn matches(&self, value: &BStr, mode: Mode) -> bool
attributes only.See if value matches this pattern in the given mode.
mode can identify value as path which won’t match the slash character, and can match
strings with cases ignored as well. Note that the case folding performed here is ASCII only.
Note that this method uses some shortcuts to accelerate simple patterns, but falls back to wildmatch() if these fail.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Pattern
impl<'de> Deserialize<'de> for Pattern
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Pattern, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Pattern, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Pattern
impl Ord for Pattern
Source§impl PartialOrd for Pattern
impl PartialOrd for Pattern
Source§impl Serialize for Pattern
impl Serialize for Pattern
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.