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 parse(src: &str) -> Result<StringPattern, StringPatternParseError>
pub fn parse(src: &str) -> Result<StringPattern, StringPatternParseError>
Parses the given string as a StringPattern
. Everything before the
first “:” is considered the string’s prefix. If the prefix is “exact:”,
“glob:”, or “substring:”, a pattern of the specified kind is returned.
Returns an error if the string has an unrecognized prefix. Otherwise, a
StringPattern::Exact
is returned.
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
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
self
and other
values to be equal, and is used
by ==
.impl Eq for StringPattern
impl StructuralPartialEq for StringPattern
Auto Trait Implementations§
impl Freeze for StringPattern
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more