Enum pica_record::matcher::field::SingletonMatcher
source · pub enum SingletonMatcher {
Subfields(SubfieldsMatcher),
Exists(ExistsMatcher),
}
Expand description
A matcher that checks for an ExistsMatcher or a SubfieldsMatcher.
Variants§
Subfields(SubfieldsMatcher)
Exists(ExistsMatcher)
Implementations§
source§impl SingletonMatcher
impl SingletonMatcher
sourcepub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
pub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
Creates a new SingletonMatcher.
§Errors
This function fails if the given expression is not a valid singleton matcher.
§Example
use pica_record::matcher::field::SingletonMatcher;
let _matcher = SingletonMatcher::new("003@.0 == '0123456789X'")?;
let _matcher = SingletonMatcher::new("041A/*?")?;
sourcepub fn is_match<'a>(
&self,
fields: impl IntoIterator<Item = &'a FieldRef<'a>>,
options: &MatcherOptions,
) -> bool
pub fn is_match<'a>( &self, fields: impl IntoIterator<Item = &'a FieldRef<'a>>, options: &MatcherOptions, ) -> bool
Returns true
if the matcher matches against the given
subfield(s).
§Example
use pica_record::matcher::field::SingletonMatcher;
use pica_record::matcher::MatcherOptions;
use pica_record::primitives::FieldRef;
let field = FieldRef::new("003@", None, vec![('0', "123456789X")])?;
let options = MatcherOptions::default();
let matcher = SingletonMatcher::new("003@.0 == '123456789X'")?;
assert!(matcher.is_match(&field, &options));
let matcher = SingletonMatcher::new("003@?")?;
assert!(matcher.is_match(&field, &options));
Trait Implementations§
source§impl Clone for SingletonMatcher
impl Clone for SingletonMatcher
source§fn clone(&self) -> SingletonMatcher
fn clone(&self) -> SingletonMatcher
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 SingletonMatcher
impl Debug for SingletonMatcher
source§impl Display for SingletonMatcher
impl Display for SingletonMatcher
source§impl PartialEq for SingletonMatcher
impl PartialEq for SingletonMatcher
impl StructuralPartialEq for SingletonMatcher
Auto Trait Implementations§
impl Freeze for SingletonMatcher
impl RefUnwindSafe for SingletonMatcher
impl Send for SingletonMatcher
impl Sync for SingletonMatcher
impl Unpin for SingletonMatcher
impl UnwindSafe for SingletonMatcher
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
)