Struct pica_record::matcher::subfield::ExistsMatcher
source · pub struct ExistsMatcher { /* private fields */ }
Expand description
A matcher that checks for the existance of subfields.
Implementations§
source§impl ExistsMatcher
impl ExistsMatcher
sourcepub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
pub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
Creates a new ExistsMatcher.
§Errors
This function fails if the given expression is not a valid exists matcher.
§Example
use pica_record::matcher::subfield::ExistsMatcher;
let _matcher = ExistsMatcher::new("a?")?;
let _matcher = ExistsMatcher::new("[a-c]?")?;
let _matcher = ExistsMatcher::new("*?")?;
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
Checks whether list of subfields contains at least one subfield with a code of the matcher’s list.
§Example
use pica_record::matcher::subfield::ExistsMatcher;
use pica_record::matcher::MatcherOptions;
use pica_record::primitives::SubfieldRef;
let options = MatcherOptions::default();
let matcher = ExistsMatcher::new("a?")?;
let subfield = SubfieldRef::new('a', "abc")?;
assert!(matcher.is_match(&subfield, &options));
let subfield = SubfieldRef::new('b', "def")?;
assert!(!matcher.is_match(&subfield, &options));
let subfields = vec![
SubfieldRef::new('b', "abc")?,
SubfieldRef::new('a', "def")?,
];
assert!(matcher.is_match(&subfields, &options));
Trait Implementations§
source§impl Clone for ExistsMatcher
impl Clone for ExistsMatcher
source§fn clone(&self) -> ExistsMatcher
fn clone(&self) -> ExistsMatcher
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 ExistsMatcher
impl Debug for ExistsMatcher
source§impl Display for ExistsMatcher
impl Display for ExistsMatcher
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Format the exists matcher as a human-readable string.
§Example
use pica_record::matcher::subfield::ExistsMatcher;
use pica_record::matcher::MatcherOptions;
use pica_record::primitives::SubfieldRef;
let matcher = ExistsMatcher::new("[a0-3]?")?;
assert_eq!(matcher.to_string(), "[a0-3]?");
source§impl PartialEq for ExistsMatcher
impl PartialEq for ExistsMatcher
impl StructuralPartialEq for ExistsMatcher
Auto Trait Implementations§
impl Freeze for ExistsMatcher
impl RefUnwindSafe for ExistsMatcher
impl Send for ExistsMatcher
impl Sync for ExistsMatcher
impl Unpin for ExistsMatcher
impl UnwindSafe for ExistsMatcher
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
)