pub struct Match { /* private fields */ }
Expand description
A Match
is a set of atomic indexes matching a given selection. It can
mostly be used like a &[usize]
.
Implementations§
source§impl Match
impl Match
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the length of the Match.
Example
let atomic_match = Match::new(&[3, 4, 5]);
assert_eq!(atomic_match.len(), 3);
sourcepub fn new(atoms: &[usize]) -> Match
pub fn new(atoms: &[usize]) -> Match
Create a new match containing the atoms in the atoms
slice.
Panics
If the slice contains more than 4 elements, which is the maximal size of a match.
Example
let atomic_match = Match::new(&[3, 4, 5]);
assert_eq!(atomic_match.len(), 3);
assert_eq!(atomic_match[0], 3);
assert_eq!(atomic_match[1], 4);
assert_eq!(atomic_match[2], 5);
sourcepub fn iter(&self) -> Iter<'_, usize>
pub fn iter(&self) -> Iter<'_, usize>
Iterate over the atomic indexes in the match.
Example
let atomic_match = Match::new(&[3, 4, 5]);
let mut iter = atomic_match.iter();
assert_eq!(iter.next(), Some(&3));
assert_eq!(iter.next(), Some(&4));
assert_eq!(iter.next(), Some(&5));
assert_eq!(iter.next(), None);