Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Base.one for StringView #24

Merged
merged 12 commits into from
Apr 25, 2024
1 change: 1 addition & 0 deletions src/StringViews.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Base.:(==)(s1::StringViewAndSub, s2::StringAndSub) = s2 == s1

Base.typemin(::Type{StringView{Vector{UInt8}}}) = StringView(Vector{UInt8}(undef,0))
Base.typemin(::T) where {T<:StringView} = typemin(T)
Base.one(::T) where {T<:StringView} = typemin(T)
mnemnion marked this conversation as resolved.
Show resolved Hide resolved

if VERSION < v"1.10.0-DEV.1007" # JuliaLang/julia#47880
Base.isvalid(s::DenseStringViewAndSub) = ccall(:u8_isvalid, Int32, (Ptr{UInt8}, Int), s, sizeof(s)) ≠ 0
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ end
@test Base.typemin(s) isa StringView{Vector{UInt8}}
@test Base.typemin(s) == ""

@test Base.one(s) == Base.typemin(s) == ""
mnemnion marked this conversation as resolved.
Show resolved Hide resolved

@test isascii(s)
@test !isascii(StringView("fööbār"))

Expand Down
Loading