Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[stdlib] Added once iterator#6604

Open
gsmyridis wants to merge 4 commits into
modular:mainfrom
gsmyridis:smy/iter-once
Open

[stdlib] Added once iterator#6604
gsmyridis wants to merge 4 commits into
modular:mainfrom
gsmyridis:smy/iter-once

Conversation

@gsmyridis

Copy link
Copy Markdown
Contributor

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
  • 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

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

  • 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
  • PR is small and focused — I've split larger changes into a sequence of
    smaller PRs where possible (see
    pull request sizes)
  • I ran ./bazelw run format to format my changes
  • I added or updated tests to cover my changes
  • 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)

@gsmyridis gsmyridis requested a review from a team as a code owner May 24, 2026 14:33
@github-actions github-actions Bot added mojo-stdlib Tag for issues related to standard library waiting-on-review labels May 24, 2026

@NathanSWard NathanSWard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks again for this! Left a few comments that should be addressed before merging in, but overall this look good!

Comment thread mojo/stdlib/std/iter/__init__.mojo Outdated
Comment thread mojo/stdlib/std/iter/__init__.mojo Outdated
Comment thread mojo/stdlib/test/iter/test_once.mojo Outdated
Comment thread mojo/stdlib/std/iter/__init__.mojo
@NathanSWard NathanSWard added waiting for response Needs action/response from contributor before a PR can proceed and removed waiting-on-review labels May 26, 2026
@gsmyridis

Copy link
Copy Markdown
Contributor Author

Thanks again for this! Left a few comments that should be addressed before merging in, but overall this look good!

Thanks for the instructive review @NathanSWard.

@NathanSWard NathanSWard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

also, looks great, thanks!

@NathanSWard

Copy link
Copy Markdown
Contributor

!sync

@modularbot modularbot added the imported-internally Signals that a given pull request has been imported internally. label May 27, 2026
@gsmyridis

Copy link
Copy Markdown
Contributor Author

Hi @NathanSWard, I wanted to follow up on the status of this PR. It has been some time that it was imported internally, but has not been merged to main yet.

I now see that there are some conflicts with the empty implementation. I resolved them, I hope this is helpful.

@NathanSWard

Copy link
Copy Markdown
Contributor

Hey @gsmyridis
Apologies for this PR falling to the wayside. I'm putting it back at the stop of my priority todos and working on merging this internally :)
There's were a few issues with our CI internally but I'm scrubbing them out and then we can officially get this merged in!

Thanks for pining me for the reminder :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

imported-internally Signals that a given pull request has been imported internally. mojo-stdlib Tag for issues related to standard library waiting for response Needs action/response from contributor before a PR can proceed waiting-on-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants