From 5e3c4d2973f4edeeadfadbdcf798fb1d5375459f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Fri, 26 Oct 2018 22:47:11 +0200 Subject: [PATCH] add IteratorSize for Char --- base/char.jl | 1 + test/char.jl | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/base/char.jl b/base/char.jl index 95c3d624b5c1a..43eb92f0470d1 100644 --- a/base/char.jl +++ b/base/char.jl @@ -187,6 +187,7 @@ size(c::AbstractChar,d) = convert(Int, d) < 1 ? throw(BoundsError()) : 1 ndims(c::AbstractChar) = 0 ndims(::Type{<:AbstractChar}) = 0 length(c::AbstractChar) = 1 +IteratorSize(::Type{Char}) = HasShape{0}() firstindex(c::AbstractChar) = 1 lastindex(c::AbstractChar) = 1 getindex(c::AbstractChar) = c diff --git a/test/char.jl b/test/char.jl index e5fca3f6807d7..3a2c54b76d3bb 100644 --- a/test/char.jl +++ b/test/char.jl @@ -286,3 +286,7 @@ end @test reinterpret(UInt32, reinterpret(Char, u)) === u end end + +@testset "broadcasting of Char" begin + @test identity.('a') == 'a' +end