[−][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 specification.
- 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.- Converting from a
&stralways means borrowing its content. However converting from aStringwill clone its content.
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> PartialEq<Glob<'a>> for Glob<'a>[src]
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> Eq for Glob<'a>[src]
impl<'a> Debug for Glob<'a>[src]
impl<'_> Display for Glob<'_>[src]
impl<'a> Hash for Glob<'a>[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
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> 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,