Enum jj_lib::str_util::StringPattern
source · pub enum StringPattern {
Exact(String),
Glob(Pattern),
Substring(String),
}
Expand description
Pattern to be tested against string property like commit description or branch name.
Variants§
Exact(String)
Matches strings exactly equal to string
.
Glob(Pattern)
Unix-style shell wildcard pattern.
Substring(String)
Matches strings that contain substring
.
Implementations§
source§impl StringPattern
impl StringPattern
sourcepub const fn everything() -> Self
pub const fn everything() -> Self
Pattern that matches any string.
sourcepub fn glob(src: &str) -> Result<Self, StringPatternParseError>
pub fn glob(src: &str) -> Result<Self, StringPatternParseError>
Parses the given string as glob pattern.
sourcepub fn from_str_kind(
src: &str,
kind: &str
) -> Result<Self, StringPatternParseError>
pub fn from_str_kind( src: &str, kind: &str ) -> Result<Self, StringPatternParseError>
Parses the given string as pattern of the specified kind
.
sourcepub fn as_exact(&self) -> Option<&str>
pub fn as_exact(&self) -> Option<&str>
Returns a literal pattern if this should match input strings exactly.
This can be used to optimize map lookup by exact key.
sourcepub fn to_glob(&self) -> Option<Cow<'_, str>>
pub fn to_glob(&self) -> Option<Cow<'_, str>>
Converts this pattern to a glob string. Returns None
if the pattern
can’t be represented as a glob.
Trait Implementations§
source§impl Clone for StringPattern
impl Clone for StringPattern
source§fn clone(&self) -> StringPattern
fn clone(&self) -> StringPattern
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for StringPattern
impl Debug for StringPattern
source§impl Display for StringPattern
impl Display for StringPattern
source§impl PartialEq for StringPattern
impl PartialEq for StringPattern
source§fn eq(&self, other: &StringPattern) -> bool
fn eq(&self, other: &StringPattern) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for StringPattern
impl StructuralEq for StringPattern
impl StructuralPartialEq for StringPattern
Auto Trait Implementations§
impl RefUnwindSafe for StringPattern
impl Send for StringPattern
impl Sync for StringPattern
impl Unpin for StringPattern
impl UnwindSafe for StringPattern
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more