Add DoubleEndedIterator support to icu_segmenter iterators
Feature Request
I would like to propose adding DoubleEndedIterator support to the iterators in icu_segmenter, in particular GraphemeClusterBreakIterator.
Motivation / Use Case
My primary use case is implementing text editor behavior.
For example, when handling the Left Arrow key or Backspace, the editor needs to move the cursor or delete the previous grapheme cluster.
Currently, icu_segmenter only supports forward iteration, which means I have to collect all break positions first and then traverse them in reverse. This is less efficient and less ergonomic.
Scope
Although my immediate need is for GraphemeClusterBreakIterator, the implementation would naturally extend to other iterators as well.
This is because GraphemeClusterBreakIterator and the other break iterators (word, sentence, line) are all built on top of the common RuleBreakIterator.
If RuleBreakIterator itself implements DoubleEndedIterator, then all higher-level iterators will automatically gain reverse-iteration capability.
I would appreciate it if the maintainers could consider this feature request.
CC @makotokato @aethanyc
Yup, supporting reverse iteration in break iterators would be useful. Firefox has a similar bug that depends on this capability in GraphemeClusterBreakIterator (see bug 1847807).