Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve first() documentation for split iterators #22374

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

axlEscalada
Copy link

Remove misleading This never fails. statement and add explicit clarification
that first() will panic if called after iteration has already begun.

Fixes #22338

lib/std/mem.zig Outdated
/// Call this only to get the first window and then use `next` to get
/// all subsequent windows.
/// If called after iteration has begun, it will panic.
Copy link
Contributor

Choose a reason for hiding this comment

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

an assertion doesnt inherently mean a panic occurs, its just a case of safety-checked undefined behavior. i think this (and the others) should say something more along the lines of Asserts that iteration has not begun, there are many cases of such phrasing across the stdlib

Copy link
Author

Choose a reason for hiding this comment

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

you're absolutely right, I will change it to follow the docs convention for these cases

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.

SplitIterator panics when doing SplitIterator.first() twice
2 participants