/// Note that there might be more than one `Reject` between two `Match`es,
/// there is no requirement for them to be combined into one.
Reject(usize, usize),
- /// Expresses that every byte of the haystack has been visted, ending
+ /// Expresses that every byte of the haystack has been visited, ending
/// the iteration.
Done
}
/// the haystack. This enables consumers of this trait to
/// slice the haystack without additional runtime checks.
pub unsafe trait Searcher<'a> {
- /// Getter for the underlaying string to be searched in
+ /// Getter for the underlying string to be searched in
///
/// Will always return the same `&str`
fn haystack(&self) -> &'a str;
fn into_searcher(self, haystack: &'a str) -> CharEqSearcher<'a, C> {
CharEqSearcher {
ascii_only: self.0.only_ascii(),
- haystack: haystack,
+ haystack,
char_eq: self.0,
char_indices: haystack.char_indices(),
}
fn new(haystack: &'a str, needle: &'b str) -> StrSearcher<'a, 'b> {
if needle.is_empty() {
StrSearcher {
- haystack: haystack,
- needle: needle,
+ haystack,
+ needle,
searcher: StrSearcherImpl::Empty(EmptyNeedle {
position: 0,
end: haystack.len(),
}
} else {
StrSearcher {
- haystack: haystack,
- needle: needle,
+ haystack,
+ needle,
searcher: StrSearcherImpl::TwoWay(
TwoWaySearcher::new(needle.as_bytes(), haystack.len())
),
TwoWaySearcher::reverse_maximal_suffix(needle, period, true));
TwoWaySearcher {
- crit_pos: crit_pos,
- crit_pos_back: crit_pos_back,
- period: period,
+ crit_pos,
+ crit_pos_back,
+ period,
byteset: Self::byteset_create(&needle[..period]),
position: 0,
- end: end,
+ end,
memory: 0,
memory_back: needle.len(),
}
// reverse search.
TwoWaySearcher {
- crit_pos: crit_pos,
+ crit_pos,
crit_pos_back: crit_pos,
period: cmp::max(crit_pos, needle.len() - crit_pos) + 1,
byteset: Self::byteset_create(needle),
position: 0,
- end: end,
+ end,
memory: usize::MAX, // Dummy value to signify that the period is long
memory_back: usize::MAX,
}
// The maximal suffix is a possible critical factorization (u', v') of `arr`.
//
// Returns `i` where `i` is the starting index of v', from the back;
- // returns immedately when a period of `known_period` is reached.
+ // returns immediately when a period of `known_period` is reached.
//
// `order_greater` determines if lexical order is `<` or `>`. Both
// orders must be computed -- the ordering with the largest `i` gives