[−][src]Struct sub_strs::Glob
Glob
This struct is used to find matches from a pattern string against some string.
The pattern string supports 2 special characters: * and ?:
*: matches any characters or nothing at all.?: matches one single character.
Notes
- The idea is inspired by https://en.wikipedia.org/wiki/Glob_%28programming%29, but this is not an implementation of that or any other specifications.
- Matches are case sensitive. If you want to ignore case, consider using
to_lowercase()(orto_uppercase()) on both pattern and target string. Displayimplementation prints parsed pattern, not the original one.- Implementations of
From<&'a str>andFrom<&'a String>always borrow the source string. - Implementations of
FromStrandFrom<String>will clone the source string.
Examples
use sub_strs::Glob; let g = Glob::from("*r?st.rs"); for s in &["rust.rs", "rEst.rs", "it's rust.rs"] { assert!(g.matches(s)); } for s in &["it's not Rust", "rest", "rust!.rs"] { assert!(g.matches(s) == false); }
Methods
impl<'a> Glob<'a>[src]
Trait Implementations
impl<'a> From<&'a str> for Glob<'a>[src]
impl<'a> From<&'a String> for Glob<'a>[src]
impl<'_> From<String> for Glob<'_>[src]
impl<'a> From<Cow<'a, str>> for Glob<'a>[src]
impl<'_> Display for Glob<'_>[src]
impl<'a> Debug for Glob<'a>[src]
impl<'a> PartialEq<Glob<'a>> for Glob<'a>[src]
impl<'a> Eq for Glob<'a>[src]
impl<'_> FromStr for Glob<'_>[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>[src]
impl<'a> Hash for Glob<'a>[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl<'a> StructuralPartialEq for Glob<'a>[src]
impl<'a> StructuralEq for Glob<'a>[src]
Auto Trait Implementations
impl<'a> Unpin for Glob<'a>
impl<'a> Send for Glob<'a>
impl<'a> Sync for Glob<'a>
impl<'a> UnwindSafe for Glob<'a>
impl<'a> RefUnwindSafe for Glob<'a>
Blanket Implementations
impl<T> From<T> for T[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,