File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -283,6 +283,16 @@ with invalid ranges. Implementations of `.search()` often start with:
283283
284284The trait is unsafe to implement because it needs to guarantee the returned range is valid.
285285
286+ There is a "reverse" version of the trait, which supports searching from the end
287+ with the ` .rsearch() ` method besides from the start.
288+
289+ Furthermore, there is a "double-ended" version, which is a marker trait saying that
290+ searching from both ends will give consistent results. The searcher of a substring needle is
291+ an example which implements ` ReverseSearcher ` but not ` DoubleEndedSearcher ` , e.g.
292+
293+ * Forward searching the needle ` xx ` in the haystack ` xxxxx ` will yield ` [xx][xx]x `
294+ * Backward searching the needle ` xx ` in the haystack ` xxxxx ` will yield ` x[xx][xx] `
295+
286296### Consumer
287297
288298A consumer provides the ` .consume() ` method to implement ` starts_with() ` and ` trim_start() ` . It
@@ -320,6 +330,8 @@ assert_eq!("GH".into_consumer().consume(span.clone()), None);
320330
321331The trait also provides a ` .trim_start() ` method in case a faster specialization exists.
322332
333+ Similar to searchers, the consumers also have the "reverse" and "double-ended" variants.
334+
323335### Needle
324336
325337A needle is simply a "factory" of a searcher and consumer.
You can’t perform that action at this time.
0 commit comments