Skip to content

Commit 5ae1b00

Browse files
committed
update to new iteration protocal
1 parent fe6c9ba commit 5ae1b00

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

src/iteration.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,13 @@ Rand(::Type{X}=Float64) where {X} = Rand(GLOBAL_RNG, X)
1616

1717
(R::Rand)(args...) = rand(R.rng, R.sp, args...)
1818

19-
Base.start(R::Rand) = R
20-
21-
function Base.next(::Union{Rand,Distribution}, R::Rand)
22-
e = R()
23-
e, R
24-
end
25-
26-
Base.done(::Union{Rand,Distribution}, ::Rand) = false
27-
19+
Base.iterate(iter::Union{Rand,Distribution}, R::Rand=iter) = R(), R
2820
Base.IteratorSize(::Type{<:Rand}) = Base.IsInfinite()
2921

3022
Base.IteratorEltype(::Type{<:Rand}) = Base.HasEltype()
3123
Base.eltype(::Type{<:Rand{R, <:Sampler{T}}}) where {R,T} = T
3224

3325
# convenience iteration over distributions
3426

35-
Base.start(d::Distribution) = Rand(GLOBAL_RNG, d)
27+
Base.iterate(d::Distribution) = iterate(Rand(GLOBAL_RNG, d))
3628
Base.IteratorSize(::Type{<:Distribution}) = Base.IsInfinite()

0 commit comments

Comments
 (0)