Struct teddy::Match
[−]
[src]
pub struct Match { pub pat: usize, pub start: usize, pub end: usize, }
All the details for the match that Teddy found.
Fields
pat: usize
The index of the pattern that matched.
The index is in correspondence with the order of the patterns given at construction. If
you've already forgotten which order that was, don't panic! You can use pat
as an index
into the result of Teddy::patterns()
.
use teddy::{Match, Teddy}; let patterns = vec![b"cat", b"dog", b"fox"]; let ted = Teddy::new(patterns.iter().map(|s| &s[..])).unwrap(); let pat = ted.find(b"The quick brown fox").unwrap().pat; assert_eq!(&ted.patterns()[pat], b"fox");
start: usize
The start byte offset of the match.
This is an index into the search string, and it is inclusive.
end: usize
The end byte offset of the match.
This is an index into the search string, and it is exclusive. That is, if m
is the
Match
struct that we got after searching through the string haystack
, then you can
retrieve the matched text using haystack[m.start..m.end]
.
Trait Implementations
impl Debug for Match
[src]
impl Clone for Match
[src]
fn clone(&self) -> Match
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more