Skip to content

Commit dafec6f

Browse files
authored
Fix startswith/endswith for Julia 1.10 (#68)
* Fix startswith/endswith for Julia 1.10 * compat for 1.6 * oops
1 parent 85fc0d1 commit dafec6f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/InlineStrings.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,9 @@ function Base.repeat(x::T, r::Integer) where {T <: InlineString}
679679
end
680680

681681
# copy/pasted from strings/util.jl
682-
function Base.startswith(a::T, b::Union{String, SubString{String}, InlineString}) where {T <: InlineString}
682+
#TODO: optimize this
683+
Base.startswith(a::InlineString, b::InlineString) = invoke(startswith, Tuple{AbstractString, AbstractString}, a, b)
684+
function Base.startswith(a::T, b::Union{String, SubString{String}}) where {T <: InlineString}
683685
cub = ncodeunits(b)
684686
ncodeunits(a) < cub && return false
685687
ref = Ref{T}(_bswap(a))
@@ -693,7 +695,9 @@ function Base.startswith(a::T, b::Union{String, SubString{String}, InlineString}
693695
end
694696
end
695697

696-
function Base.endswith(a::T, b::Union{String, SubString{String}, InlineString}) where {T <: InlineString}
698+
#TODO: optimize this
699+
Base.endswith(a::InlineString, b::InlineString) = invoke(endswith, Tuple{AbstractString, AbstractString}, a, b)
700+
function Base.endswith(a::T, b::Union{String, SubString{String}}) where {T <: InlineString}
697701
cub = ncodeunits(b)
698702
astart = ncodeunits(a) - ncodeunits(b) + 1
699703
astart < 1 && return false

0 commit comments

Comments
 (0)