Struct pica_record::matcher::subfield::InMatcher
source · pub struct InMatcher { /* private fields */ }
Expand description
A matcher that checks if a subfield value is in a predefined list.
Implementations§
source§impl InMatcher
impl InMatcher
sourcepub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
pub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
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, where the
value is contained in the matcher list.
§Example
use pica_record::matcher::subfield::InMatcher;
use pica_record::matcher::MatcherOptions;
use pica_record::primitives::SubfieldRef;
let options = MatcherOptions::default();
let subfield = SubfieldRef::new('0', "Tp1")?;
let matcher = InMatcher::new("0 in ['Tp1', 'Tpz']")?;
assert!(matcher.is_match(&subfield, &options));
let matcher = InMatcher::new("0 not in ['Ts1', 'Tsz']")?;
assert!(matcher.is_match(&subfield, &options));
Trait Implementations§
source§impl Display for InMatcher
impl Display for InMatcher
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Format the in-matcher as a human-readable string.
§Example
use pica_record::matcher::subfield::InMatcher;
use pica_record::matcher::MatcherOptions;
let matcher = InMatcher::new("ANY [ab] in ['foo', 'bar']")?;
assert_eq!(matcher.to_string(), "ANY [ab] in ['foo', 'bar']");
impl Eq for InMatcher
impl StructuralPartialEq for InMatcher
Auto Trait Implementations§
impl Freeze for InMatcher
impl RefUnwindSafe for InMatcher
impl Send for InMatcher
impl Sync for InMatcher
impl Unpin for InMatcher
impl UnwindSafe for InMatcher
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
)