[stdlib] Added empty iterator#6603
Conversation
|
Is the location of the additions correct? |
empty iterator
|
Thanks for this @gsmyridis - left a round of feedback, but after the comments get addressed, this PR looks good to go :) |
Thanks again @NathanSWard for the feedback. |
NathanSWard
left a comment
There was a problem hiding this comment.
looks great, thank you!
|
!sync |
|
✅🟣 This contribution has been merged 🟣✅ Your pull request has been merged to the internal upstream Mojo sources. It will be reflected here in the Mojo repository on the main branch during the next Mojo nightly release, typically within the next 24-48 hours. We use Copybara to merge external contributions, click here to learn more. |
|
Landed in 98ff260! Thank you for your contribution 🎉 |
[External] [stdlib] Added `once` iterator ## Linked issue Partly addresses #6589 along with PR #6603. ## Type of change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] Performance improvement (includes benchmark results below) - [ ] Documentation update - [x] New feature or public API (requires prior proposal or issue approval) - [ ] Refactor / internal cleanup (no user-visible change) - [ ] Build, CI, or tooling change ## Motivation Discussed in #6589. ## What changed Added the `once` iterator, that yields an element exactly once. For instance ```mojo from std.iter import once from std.testing import assert_equal, assert_raises var it = once(10) assert_equal(next(it), 10) with assert_raises(): _ = next(it) ``` ## Testing Added new tests and successfully ran the full test suite. ## Checklist - [x] The linked issue above has been reviewed by a maintainer and is agreed-upon, or this is a trivial fix that does not need prior approval - [x] PR is small and focused — I've split larger changes into a sequence of smaller PRs where possible (see [pull request sizes](https://github.com/modular/modular/blob/main/mojo/CONTRIBUTING.md#about-pull-request-sizes)) - [x] I ran `./bazelw run format` to format my changes - [x] I added or updated tests to cover my changes - [x] If AI tools assisted with this contribution, I have included an `Assisted-by:` trailer in my commit message or this PR description (see [AI Tool Use Policy](https://github.com/modular/modular/blob/main/AI_TOOL_POLICY.md)) ORIGINAL_AUTHOR=Giorgos Smyridis <[email protected]> ORIGINAL_USER=@gsmyridis --------- Co-authored-by: Giorgos Smyridis <[email protected]> Co-authored-by: Nathan Ward <[email protected]> Closes #6604 MODULAR_ORIG_COMMIT_REV_ID: 4c61169baa6c936df9b88e18381a6a1bed89ee89
Linked issue
Partly addresses #6589
Type of change
Motivation
Discussed in #6589.
What changed
Added an empty iterator, that yields nothing.
Testing
Added new tests and successfully ran the whole test suite.
Checklist
agreed-upon, or this is a trivial fix that does not need prior
approval
smaller PRs where possible (see
pull request sizes)
./bazelw run formatto format my changesAssisted-by:trailer in my commit message or this PR description (seeAI Tool Use Policy)