Enum pica_record::matcher::subfield::SingletonMatcher
source · pub enum SingletonMatcher {
Cardinality(CardinalityMatcher),
Regex(RegexMatcher),
RegexSet(RegexSetMatcher),
Relation(RelationMatcher),
Exists(ExistsMatcher),
In(InMatcher),
}
Expand description
A matcher that checks for the singleton matcher.
This matcher combines all atomic, singleton matcher into a new matcher.
Variants§
Cardinality(CardinalityMatcher)
Regex(RegexMatcher)
RegexSet(RegexSetMatcher)
Relation(RelationMatcher)
Exists(ExistsMatcher)
In(InMatcher)
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 cardinality-matcher.
§Example
use pica_record::matcher::subfield::CardinalityMatcher;
let _matcher = CardinalityMatcher::new("#a > 5")?;
sourcepub fn is_match<'a>(
&self,
subfields: impl IntoIterator<Item = &'a SubfieldRef<'a>>,
options: &MatcherOptions,
) -> bool
pub fn is_match<'a>( &self, subfields: impl IntoIterator<Item = &'a SubfieldRef<'a>>, options: &MatcherOptions, ) -> bool
Returns true
if the underlying matcher returns true
.
§Example
use pica_record::matcher::subfield::SingletonMatcher;
use pica_record::matcher::MatcherOptions;
use pica_record::primitives::SubfieldRef;
let options = MatcherOptions::default();
let subfield = SubfieldRef::new('a', "foo")?;
let matcher = SingletonMatcher::new("a == 'foo'")?;
assert!(matcher.is_match(&subfield, &options));
let matcher = SingletonMatcher::new("#a == 1")?;
assert!(matcher.is_match(&subfield, &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
)