Skip to content

attributed_text: make AttributeSegments report exact length#557

Merged
waywardmonkeys merged 1 commit intolinebender:mainfrom
waywardmonkeys:attribute-segments-size-hint
Feb 18, 2026
Merged

attributed_text: make AttributeSegments report exact length#557
waywardmonkeys merged 1 commit intolinebender:mainfrom
waywardmonkeys:attribute-segments-size-hint

Conversation

@waywardmonkeys
Copy link
Contributor

Implement exact iterator cardinality for AttributeSegments by adding:

  • Iterator::size_hint with exact lower/upper bounds
  • ExactSizeIterator with len()

AttributeSegments iterates over remaining adjacent boundary pairs, so remaining item count is exactly boundaries.len() - 1 - index.

Also adds a regression test that validates size_hint as iteration advances.

Implement exact iterator cardinality for `AttributeSegments` by adding:
- `Iterator::size_hint` with exact lower/upper bounds
- `ExactSizeIterator` with `len()`

`AttributeSegments` iterates over remaining adjacent boundary pairs, so
remaining item count is exactly `boundaries.len() - 1 - index`.

Also adds a regression test that validates `size_hint` as iteration
advances.
@waywardmonkeys waywardmonkeys force-pushed the attribute-segments-size-hint branch from f503cae to 6946808 Compare February 18, 2026 01:57
@waywardmonkeys waywardmonkeys added this pull request to the merge queue Feb 18, 2026
Merged via the queue into linebender:main with commit 5a70471 Feb 18, 2026
24 checks passed
@waywardmonkeys waywardmonkeys deleted the attribute-segments-size-hint branch February 18, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments