pub enum Chunk {
Str(String),
Wildcard,
UnknownChar,
}Expand description
A part of a Pattern.
Used to configure a compiled Pattern.
Variants§
Str(String)
A literal string. This matches the string exactly.
Wildcard
A wildcard (usually represented by an asterisk). Matches any amount of characters, including none.
UnknownChar
An unknown character (usually represented by a question mark).
Implementations§
Trait Implementations§
Source§impl FromIterator<Chunk> for Pattern
impl FromIterator<Chunk> for Pattern
Source§fn from_iter<T: IntoIterator<Item = Chunk>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Chunk>>(iter: T) -> Self
Used to compile a Pattern from an iterator of Chunks.
Note that this allocates memory to store all the Chunks.
Example usage:
use patmatch::{Pattern, Chunk};
let chunk_vec = vec![Chunk::str("IMG_"), Chunk::Wildcard, Chunk::str(".png")];
let pat: Pattern = chunk_vec.into_iter().collect();
assert!(pat.matches("IMG_20170301.png"));
assert!(!pat.matches("stuff.png")); assert!(!pat.matches("IMG_20170302.jpeg"));impl Eq for Chunk
impl StructuralPartialEq for Chunk
Auto Trait Implementations§
impl Freeze for Chunk
impl RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin for Chunk
impl UnwindSafe for Chunk
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