pub struct Pattern {
pub text: BString,
pub mode: Mode,
pub first_wildcard_pos: Option<usize>,
}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
impl Pattern
Instantiation
sourcepub fn from_bytes(text: &[u8]) -> Option<Self>
pub fn from_bytes(text: &[u8]) -> Option<Self>
Parse the given text as pattern, or return None if text was empty.
sourcepub fn from_bytes_without_negation(text: &[u8]) -> Option<Self>
pub fn from_bytes_without_negation(text: &[u8]) -> Option<Self>
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
impl Pattern
Access
sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
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
pub fn matches_repo_relative_path( &self, path: &BStr, basename_start_pos: Option<usize>, is_dir: Option<bool>, case: Case, mode: Mode ) -> bool
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
pub fn matches(&self, value: &BStr, mode: Mode) -> bool
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Ord for Pattern
impl Ord for Pattern
source§impl PartialEq for Pattern
impl PartialEq for Pattern
source§impl PartialOrd for Pattern
impl PartialOrd 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