Skip to content

attributed_text: add IntoIterator support for ActiveSpans#556

Merged
waywardmonkeys merged 1 commit intolinebender:mainfrom
waywardmonkeys:active-spans-into-iterator
Feb 18, 2026
Merged

attributed_text: add IntoIterator support for ActiveSpans#556
waywardmonkeys merged 1 commit intolinebender:mainfrom
waywardmonkeys:active-spans-into-iterator

Conversation

@waywardmonkeys
Copy link
Contributor

Implement IntoIterator for &ActiveSpans so callers can iterate with for loops without extra allocation.

Expose ActiveSpansIter and ActiveSpansIterRev, update docs with an &active_spans loop example, and add a unit test for reference iteration semantics.

@waywardmonkeys waywardmonkeys force-pushed the active-spans-into-iterator branch from 37c9872 to f61adff Compare February 18, 2026 01:45
Copy link
Member

@tomcur tomcur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could consider dropping the implementations of ActiveSpansIter / ActiveSpansIterRev, and write something like self.active_ids.iter().map(|id| self.attributed.attribute_at_idx(id as usize).expect("...")). That could still return a nameable type if desired, wrapping the Map<...> (e.g. ActiveSpansIterRev::ids already wraps Rev<Iter<...>> itself); but could also just return impl ExactSizeIterator.

Implement `IntoIterator` for `&ActiveSpans` so callers can iterate with for loops without extra allocation.

Expose `ActiveSpansIter` and `ActiveSpansIterRev`, update docs with an `&active_spans` loop example, and add a unit test for reference iteration semantics.
@waywardmonkeys waywardmonkeys force-pushed the active-spans-into-iterator branch from f61adff to 83d3f9b Compare February 18, 2026 15:42
@waywardmonkeys waywardmonkeys added this pull request to the merge queue Feb 18, 2026
@waywardmonkeys
Copy link
Contributor Author

Opting out of the last request!

Merged via the queue into linebender:main with commit 3f2998b Feb 18, 2026
24 checks passed
@waywardmonkeys waywardmonkeys deleted the active-spans-into-iterator branch February 18, 2026 16:05
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