The SimpleTraits.jl solution fails because numbers are iterable:
using SimpleTraits
using SimpleTraits.BaseTraits
@traitfn f(x::T) where {T; IsIterator{T}} = "iterable"
@traitfn f(x::T) where {T; !IsIterator{T}} = "not iterable"
I get
julia> f((1,2))
"iterable"
julia> f([1,2])
"iterable"
julia> struct A
end
julia> f(A)
"not iterable"
which looks great, but then
julia> f(1.0)
"iterable"