Skip to content

Commit 7a92e17

Browse files
ararslanfredrikekre
authored andcommitted
Add pushfirst! and popfirst! (#444)
1 parent 423a025 commit 7a92e17

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ Currently, the `@compat` macro supports the following syntaxes:
264264

265265
* `Void` is now `Nothing` with an alias `Cvoid` for C interop ([#25162]).
266266

267+
* `unshift!` and `shift!` are now `pushfirst!` and `popfirst!` ([#25100]).
268+
267269
## New macros
268270

269271
* `@__DIR__` has been added ([#18380])
@@ -419,5 +421,6 @@ includes this fix. Find the minimum version from there.
419421
[#25021]: https://github.com/JuliaLang/julia/issues/25021
420422
[#25056]: https://github.com/JuliaLang/julia/issues/25056
421423
[#25057]: https://github.com/JuliaLang/julia/issues/25057
424+
[#25100]: https://github.com/JuliaLang/julia/issues/25100
422425
[#25102]: https://github.com/JuliaLang/julia/issues/25102
423426
[#25162]: https://github.com/JuliaLang/julia/issues/25162

src/Compat.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,13 @@ else
10521052
import Base: notnothing
10531053
end
10541054

1055+
# 0.7.0-DEV.3155
1056+
@static if !isdefined(Base, :pushfirst!)
1057+
const pushfirst! = unshift!
1058+
const popfirst! = shift!
1059+
export pushfirst!, popfirst!
1060+
end
1061+
10551062
include("deprecated.jl")
10561063

10571064
end # module Compat

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,6 +1063,12 @@ end
10631063
@test Compat.notnothing(1) == 1
10641064
@test_throws ArgumentError Compat.notnothing(nothing)
10651065

1066+
# 0.7.0-DEV.3155
1067+
let coolvec = [1,2,3]
1068+
@test pushfirst!(coolvec, 0) == [0,1,2,3]
1069+
@test popfirst!(coolvec) == 0
1070+
end
1071+
10661072
if VERSION < v"0.6.0"
10671073
include("deprecated.jl")
10681074
end

0 commit comments

Comments
 (0)