Skip to content

Commit 0305622

Browse files
Update to new iteration interface
1 parent 82bdb7a commit 0305622

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

base/iterators.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,12 +1101,13 @@ Returns the one and only element of collection `x`, and throws an error if the c
11011101
has zero or multiple elements.
11021102
"""
11031103
Base.@propagate_inbounds function only(x)
1104-
i = start(x)
1105-
@boundscheck if done(x, i)
1104+
i = iterate(x)
1105+
@boundscheck if i === nothing
11061106
error("Collection is empty, must contain exactly 1 element")
11071107
end
1108-
(ret, i) = next(x, i)
1109-
@boundscheck if !done(x, i)
1108+
(ret, state) = i
1109+
j = iterate(x, state)
1110+
@boundscheck if j !== nothing
11101111
error("Collection has multiple elements, must contain exactly 1 element")
11111112
end
11121113
return ret

0 commit comments

Comments
 (0)