diff --git a/src/components.jl b/src/components.jl index 8635c71b..c9b03d41 100644 --- a/src/components.jl +++ b/src/components.jl @@ -523,9 +523,12 @@ mutable struct EachAnn x y end -Base.start(ea::EachAnn) = 1 -Base.done(ea::EachAnn, i) = ea.anns == nothing || isempty(ea.anns.strs) || i > length(ea.y) -function Base.next(ea::EachAnn, i) + +function Base.iterate(ea::EachAnn, i = 1) + if ea.anns == nothing || isempty(ea.anns.strs) || i > length(ea.y) + return nothing + end + tmp = _cycle(ea.anns.strs,i) str,fnt = if isa(tmp, PlotText) tmp.str, tmp.font diff --git a/src/utils.jl b/src/utils.jl index 591b0e8e..e20f9453 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -215,15 +215,13 @@ anynan(i::Int, args::Tuple) = any(a -> try isnan(_cycle(a,i)) catch MethodError anynan(istart::Int, iend::Int, args::Tuple) = any(i -> anynan(i, args), istart:iend) allnan(istart::Int, iend::Int, args::Tuple) = all(i -> anynan(i, args), istart:iend) -function Base.start(itr::SegmentsIterator) - nextidx = 1 - if !any(isempty,itr.args) && anynan(1, itr.args) - _, nextidx = next(itr, 1) +Base.iterate(itr::SegmentsIterator, nextidx::Int) = +function Base.next(itr::SegmentsIterator, nextidx::Int = 1) + nextidx > itr.n && return nothing + if nextidx == 1 && !any(isempty,itr.args) && anynan(1, itr.args) + nextidx = 2 end - nextidx -end -Base.done(itr::SegmentsIterator, nextidx::Int) = nextidx > itr.n -function Base.next(itr::SegmentsIterator, nextidx::Int) + i = istart = iend = nextidx # find the next NaN, and iend is the one before