Enum pica_record::matcher::OccurrenceMatcher
source · pub enum OccurrenceMatcher {
Exact(Occurrence),
Range(Occurrence, Occurrence),
None,
Any,
}
Expand description
A matcher that matches against a OccurrenceRef.
Variants§
Implementations§
source§impl OccurrenceMatcher
impl OccurrenceMatcher
sourcepub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
pub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
Creates a new OccurrenceMatcher.
§Errors
This function fails if the given expression is not a valid occurrence matcher.
§Example
use pica_record::matcher::OccurrenceMatcher;
let _matcher = OccurrenceMatcher::new("/01")?;
let _matcher = OccurrenceMatcher::new("/01-09")?;
let _matcher = OccurrenceMatcher::new("/001")?;
let _matcher = OccurrenceMatcher::new("/*")?;
sourcepub fn is_match(&self, other: Option<&OccurrenceRef<'_>>) -> bool
pub fn is_match(&self, other: Option<&OccurrenceRef<'_>>) -> bool
Returns true
if the given occurrence matches against the
matcher.
§Example
use pica_record::matcher::OccurrenceMatcher;
use pica_record::primitives::OccurrenceRef;
let matcher = OccurrenceMatcher::new("/01-03")?;
assert!(matcher.is_match(Some(&OccurrenceRef::new("02")?)));
assert!(!matcher.is_match(Some(&OccurrenceRef::new("04")?)));
let matcher = OccurrenceMatcher::new("/*")?;
assert!(matcher.is_match(None));
Trait Implementations§
source§impl Clone for OccurrenceMatcher
impl Clone for OccurrenceMatcher
source§fn clone(&self) -> OccurrenceMatcher
fn clone(&self) -> OccurrenceMatcher
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for OccurrenceMatcher
impl Debug for OccurrenceMatcher
source§impl Display for OccurrenceMatcher
impl Display for OccurrenceMatcher
source§impl PartialEq for OccurrenceMatcher
impl PartialEq for OccurrenceMatcher
impl StructuralPartialEq for OccurrenceMatcher
Auto Trait Implementations§
impl Freeze for OccurrenceMatcher
impl RefUnwindSafe for OccurrenceMatcher
impl Send for OccurrenceMatcher
impl Sync for OccurrenceMatcher
impl Unpin for OccurrenceMatcher
impl UnwindSafe for OccurrenceMatcher
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)