Struct pica_record::matcher::subfield::RegexSetMatcher
source · pub struct RegexSetMatcher { /* private fields */ }
Expand description
A matcher that checks a subfield value against a regex set.
Implementations§
source§impl RegexSetMatcher
impl RegexSetMatcher
sourcepub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
pub fn new(matcher: &str) -> Result<Self, ParseMatcherError>
Creates a new RegexSetMatcher.
§Errors
This function fails if the given expression is not a valid regex-set matcher.
§Example
use pica_record::matcher::subfield::RegexMatcher;
let _matcher = RegexMatcher::new("0 =~ '^Tp'")?;
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 (ANY) or all (ALL) subfield values matches against the regular expression.
§Example
use pica_record::matcher::subfield::RegexSetMatcher;
use pica_record::matcher::MatcherOptions;
use pica_record::primitives::SubfieldRef;
let options = MatcherOptions::default();
let subfield = SubfieldRef::new('0', "Tp1")?;
let matcher = RegexSetMatcher::new("0 =~ ['^Ts', '^Tp']")?;
assert!(matcher.is_match(&subfield, &options));
let matcher = RegexSetMatcher::new("0 !~ ['^Ts', '^Tu']")?;
assert!(matcher.is_match(&subfield, &options));
Trait Implementations§
source§impl Clone for RegexSetMatcher
impl Clone for RegexSetMatcher
source§fn clone(&self) -> RegexSetMatcher
fn clone(&self) -> RegexSetMatcher
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 RegexSetMatcher
impl Debug for RegexSetMatcher
source§impl Display for RegexSetMatcher
impl Display for RegexSetMatcher
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Format the regex-set matcher as a human-readable string.
§Example
use pica_record::matcher::subfield::RegexSetMatcher;
use pica_record::matcher::MatcherOptions;
let matcher =
RegexSetMatcher::new("ANY [ab] !~ ['^f.*o$', 'bar']")?;
assert_eq!(matcher.to_string(), "ANY [ab] !~ ['^f.*o$', 'bar']");
source§impl PartialEq for RegexSetMatcher
impl PartialEq for RegexSetMatcher
impl StructuralPartialEq for RegexSetMatcher
Auto Trait Implementations§
impl Freeze for RegexSetMatcher
impl RefUnwindSafe for RegexSetMatcher
impl Send for RegexSetMatcher
impl Sync for RegexSetMatcher
impl Unpin for RegexSetMatcher
impl UnwindSafe for RegexSetMatcher
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
)