File tree 1 file changed +12
-0
lines changed 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:
283
283
284
284
The trait is unsafe to implement because it needs to guarantee the returned range is valid.
285
285
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
+
286
296
### Consumer
287
297
288
298
A 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);
320
330
321
331
The trait also provides a ` .trim_start() ` method in case a faster specialization exists.
322
332
333
+ Similar to searchers, the consumers also have the "reverse" and "double-ended" variants.
334
+
323
335
### Needle
324
336
325
337
A needle is simply a "factory" of a searcher and consumer.
You can’t perform that action at this time.
0 commit comments