Skip to content

Commit

Permalink
Allow AbstractUnitRange for string getindex (JuliaLang#41807)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkitti authored and LilithHafner committed Mar 8, 2022
1 parent d8aba28 commit 171357d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/strings/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function getindex_continued(s::String, i::Int, u::UInt32)
return reinterpret(Char, u)
end

getindex(s::String, r::UnitRange{<:Integer}) = s[Int(first(r)):Int(last(r))]
getindex(s::String, r::AbstractUnitRange{<:Integer}) = s[Int(first(r)):Int(last(r))]

@inline function getindex(s::String, r::UnitRange{Int})
isempty(r) && return ""
Expand Down
2 changes: 1 addition & 1 deletion base/strings/substring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,4 @@ function filter(f, s::Union{String, SubString{String}})
return String(out)
end

getindex(s::AbstractString, r::UnitRange{<:Integer}) = SubString(s, r)
getindex(s::AbstractString, r::AbstractUnitRange{<:Integer}) = SubString(s, r)

0 comments on commit 171357d

Please sign in to comment.