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

Add precision about stateful iterators to isempty #43900

Merged
merged 3 commits into from
Mar 2, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update base/essentials.jl
  • Loading branch information
nalimilan committed Mar 2, 2022
commit 22b448696fc0b6749f472a17fca659855ffc7be7
8 changes: 6 additions & 2 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,12 @@ inferencebarrier(@nospecialize(x)) = Ref{Any}(x)[]

Determine whether a collection is empty (has no elements).

This operation is guaranteed not to consume elements even for stateful
iterators (which should define [`Base.isdone`](@ref) to that end).
!!! warning

`isempty(itr)` may consume the next element of a stateful iterator `itr`
unless an appropriate [`Base.isdone(itr)`](@ref) or `isempty` method is defined.
Use of `isempty` should therefore be avoided when writing generic
code which should support any iterator type.

# Examples
```jldoctest
Expand Down