Struct pica_record::matcher::subfield::RelationMatcher
source · pub struct RelationMatcher { /* private fields */ }
Expand description
A matcher that checks relations between (string) values.
Implementations§
source§impl RelationMatcher
impl RelationMatcher
sourcepub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
pub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
Creates a new RelationMatcher.
§Errors
This function fails if the given expression is not a valid relation matcher.
§Example
use pica_record::matcher::subfield::RelationMatcher;
let _matcher = RelationMatcher::new("0 == 'Tp1'")?;
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 at least one subfield is found, when the subfield’s value and the matcher value are related. The two values are related iff the relation defined by the operator exists.
§Example
use pica_record::matcher::subfield::RelationMatcher;
use pica_record::matcher::MatcherOptions;
use pica_record::primitives::SubfieldRef;
let options = MatcherOptions::default();
let matcher = RelationMatcher::new("0 == 'Tp1'")?;
let subfield = SubfieldRef::new('0', "Tp1")?;
assert!(matcher.is_match(&subfield, &options));
Trait Implementations§
source§impl Clone for RelationMatcher
impl Clone for RelationMatcher
source§fn clone(&self) -> RelationMatcher
fn clone(&self) -> RelationMatcher
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 RelationMatcher
impl Debug for RelationMatcher
source§impl Display for RelationMatcher
impl Display for RelationMatcher
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Format the relation matcher as a human-readable string.
§Example
use pica_record::matcher::subfield::RelationMatcher;
use pica_record::matcher::MatcherOptions;
use pica_record::primitives::SubfieldRef;
let matcher = RelationMatcher::new("[a0-3] == 'foo'")?;
assert_eq!(matcher.to_string(), "[a0-3] == 'foo'");
source§impl PartialEq for RelationMatcher
impl PartialEq for RelationMatcher
impl Eq for RelationMatcher
impl StructuralPartialEq for RelationMatcher
Auto Trait Implementations§
impl Freeze for RelationMatcher
impl RefUnwindSafe for RelationMatcher
impl Send for RelationMatcher
impl Sync for RelationMatcher
impl Unpin for RelationMatcher
impl UnwindSafe for RelationMatcher
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
)