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

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");

The start byte offset of the match.

This is an index into the search string, and it is inclusive.

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]

Formats the value using the given formatter.

impl Clone for Match
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Match
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.