Struct SetMatches
pub struct SetMatches(/* private field */);
A set of matches returned by a regex set.
Values of this type are constructed by RegexSet::matches.
Implementations
impl SetMatches
fn matched_any(&self) -> boolWhether this set contains any matches.
Example
use RegexSet; let set = new.unwrap; let matches = set.matches; assert!;fn matched_all(&self) -> boolWhether all patterns in this set matched.
Example
use RegexSet; let set = new.unwrap; let matches = set.matches; assert!;fn matched(&self, index: usize) -> boolWhether the regex at the given index matched.
The index for a regex is determined by its insertion order upon the initial construction of a
RegexSet, starting at0.Panics
If
indexis greater than or equal to the number of regexes in the original set that produced these matches. Equivalently, whenindexis greater than or equal toSetMatches::len.Example
use RegexSet; let set = new.unwrap; let matches = set.matches; assert!; assert!;fn len(&self) -> usizeThe total number of regexes in the set that created these matches.
WARNING: This always returns the same value as
RegexSet::len. In particular, it does not return the number of elements yielded bySetMatches::iter. The only way to determine the total number of matched regexes is to iterate over them.Example
Notice that this method returns the total number of regexes in the original set, and not the total number of regexes that matched.
use RegexSet; let set = new.unwrap; let matches = set.matches; // Total number of patterns that matched. assert_eq!; // Total number of patterns in the set. assert_eq!;fn iter(&self) -> SetMatchesIter<'_>Returns an iterator over the indices of the regexes that matched.
This will always produces matches in ascending order, where the index yielded corresponds to the index of the regex that matched with respect to its position when initially building the set.
Example
use RegexSet; let set = new.unwrap; let hay = "βa1"; let matches: = set.matches.iter.collect; assert_eq!;Note that
SetMatchesalso implements theIntoIteratortrait, so this method is not always needed. For example:use RegexSet; let set = new.unwrap; let hay = "βa1"; let mut matches = vec!; for index in set.matches assert_eq!;
Trait Implementations
impl Clone for SetMatches
fn clone(&self) -> SetMatches
impl Debug for SetMatches
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl IntoIterator for SetMatches
type IntoIter = SetMatchesIntoIter;type Item = usize;fn into_iter(self) -> Self::IntoIter
Auto Trait Implementations
impl Freeze for SetMatches
impl RefUnwindSafe for SetMatches
impl Send for SetMatches
impl Sync for SetMatches
impl Unpin for SetMatches
impl UnsafeUnpin for SetMatches
impl UnwindSafe for SetMatches
Blanket Implementations
impl<T> Any for SetMatches
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for SetMatches
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for SetMatches
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for SetMatches
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for SetMatches
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for SetMatches
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for SetMatches
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for SetMatches
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for SetMatches
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>