Skip to content

Commit d5b9b6e

Browse files
author
Christopher Doris
committed
fix some method invalidations
1 parent 89831cc commit d5b9b6e

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/utils.jl

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,26 +172,22 @@ module Utils
172172
StaticString{T,N}(codeunits::NTuple{N,T}) where {T,N} = new{T,N}(codeunits)
173173
end
174174

175-
function Base.convert(::Type{String}, x::StaticString)
175+
function Base.print(io::IO, x::StaticString)
176176
cs = collect(x.codeunits)
177177
i = findfirst(==(0), cs)
178-
transcode(String, i===nothing ? cs : cs[1:i-1])
178+
print(io, transcode(String, i===nothing ? cs : cs[1:i-1]))
179179
end
180180

181-
Base.String(x::StaticString) = convert(String, x)
182-
183-
function Base.convert(::Type{StaticString{T,N}}, x::String) where {T,N}
184-
cs = transcode(T, x)
181+
function Base.convert(::Type{StaticString{T,N}}, x::AbstractString) where {T,N}
182+
cs = collect(transcode(T, convert(String, x)))
185183
length(cs) > N && throw(InexactError(:convert, StaticString{T,N}, x))
186184
while length(cs) < N
187185
push!(cs, 0)
188186
end
189187
StaticString{T,N}(NTuple{N,T}(cs))
190188
end
191189

192-
Base.convert(::Type{T}, x::AbstractString) where {T<:StaticString} = convert(T, convert(String, x))
193-
194-
(::Type{T})(x::AbstractString) where {T<:StaticString} = convert(T, x)
190+
StaticString{T,N}(x::AbstractString) where {T,N} = convert(StaticString{T,N}, x)
195191

196192
function Base.iterate(x::StaticString, st::Union{Nothing,Tuple}=nothing)
197193
if st === nothing

0 commit comments

Comments
 (0)