pub struct Glob<'a> { /* private fields */ }Expand description
§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);
}Implementations§
Trait Implementations§
Source§impl<'a> Ord for Glob<'a>
impl<'a> Ord for Glob<'a>
Source§impl<'a> PartialOrd for Glob<'a>
impl<'a> PartialOrd for Glob<'a>
impl<'a> Eq for Glob<'a>
impl<'a> StructuralPartialEq for Glob<'a>
Auto Trait Implementations§
impl<'a> Freeze for Glob<'a>
impl<'a> RefUnwindSafe for Glob<'a>
impl<'a> Send for Glob<'a>
impl<'a> Sync for Glob<'a>
impl<'a> Unpin for Glob<'a>
impl<'a> UnwindSafe for Glob<'a>
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