diff --git a/README.md b/README.md index 66fe9424a..7cbf3a319 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,9 @@ Currently, the `@compat` macro supports the following syntaxes: * `Some{T}` wraps `T` to signify that a result of `T<:Void` is expected ([#23642]). +* `replace` accepts a pair of pattern and replacement, with the number of replacements as + a keyword argument ([#25165]). + ## Renaming @@ -266,6 +269,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `unshift!` and `shift!` are now `pushfirst!` and `popfirst!` ([#25100]). +* `ipermute!` is now `invpermute!` ([#25168]). + ## New macros * `@__DIR__` has been added ([#18380]) @@ -424,3 +429,5 @@ includes this fix. Find the minimum version from there. [#25100]: https://github.com/JuliaLang/julia/issues/25100 [#25102]: https://github.com/JuliaLang/julia/issues/25102 [#25162]: https://github.com/JuliaLang/julia/issues/25162 +[#25165]: https://github.com/JuliaLang/julia/issues/25165 +[#25168]: https://github.com/JuliaLang/julia/issues/25168 diff --git a/src/Compat.jl b/src/Compat.jl index 3ba7430e4..bc1d94acd 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1059,6 +1059,17 @@ end export pushfirst!, popfirst! end +# 0.7.0-DEV.3173 +@static if !isdefined(Base, :invpermute!) + const invpermute! = ipermute! + export invpermute! +end + +@static if VERSION < v"0.7.0-DEV.3172" + Base.replace(s::AbstractString, pat_rep::Pair; count::Integer=typemax(Int)) = + replace(s, first(pat_rep), last(pat_rep), count) +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index 21f14bd4e..b03fbde9a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1069,6 +1069,13 @@ let coolvec = [1,2,3] @test popfirst!(coolvec) == 0 end +# 0.7.0-DEV.3173 +@test invpermute!(permute!([1, 2], 2:-1:1), 2:-1:1) == [1, 2] + +# 0.7.0-DEV.3172 +@test replace("abcb", "b"=>"c") == "accc" +@test replace("abcb", "b"=>"c", count=1) == "accb" + if VERSION < v"0.6.0" include("deprecated.jl") end