Skip to content

Add DoubleEndedIterator support to icu_segmenter iterators #6996

@White-Green

Description

@White-Green

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions