Skip to content

Commit 36d879c

Browse files
authored
Compat.IteratorSize and Compat.IteratorEltype (#451)
1 parent 3c1d4fc commit 36d879c

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ Currently, the `@compat` macro supports the following syntaxes:
273273

274274
* `unshift!` and `shift!` are now `pushfirst!` and `popfirst!` ([#25100]).
275275

276+
* `Base.IteratorSize` and `Base.IteratorEltype` are available as
277+
`Compat.IteratorSize` and `Compat.IteratorEltype` ([#25402]).
278+
276279
* `copy!` and `unsafe_copy!` are now `copyto!` and `unsafe_copyto!` ([#24808]).
277280

278281
* `ipermute!` is now `invpermute!` ([#25168]).
@@ -428,13 +431,16 @@ includes this fix. Find the minimum version from there.
428431
[#24657]: https://github.com/JuliaLang/julia/issues/24657
429432
[#24714]: https://github.com/JuliaLang/julia/issues/24714
430433
[#24785]: https://github.com/JuliaLang/julia/issues/24785
434+
[#24808]: https://github.com/JuliaLang/julia/issues/24808
431435
[#25012]: https://github.com/JuliaLang/julia/issues/25012
432436
[#25021]: https://github.com/JuliaLang/julia/issues/25021
433437
[#25056]: https://github.com/JuliaLang/julia/issues/25056
434438
[#25057]: https://github.com/JuliaLang/julia/issues/25057
435439
[#25100]: https://github.com/JuliaLang/julia/issues/25100
436440
[#25102]: https://github.com/JuliaLang/julia/issues/25102
441+
[#25113]: https://github.com/JuliaLang/julia/issues/25113
437442
[#25162]: https://github.com/JuliaLang/julia/issues/25162
438443
[#25165]: https://github.com/JuliaLang/julia/issues/25165
439444
[#25168]: https://github.com/JuliaLang/julia/issues/25168
440-
[#25113]: https://github.com/JuliaLang/julia/issues/25113
445+
[#25227]: https://github.com/JuliaLang/julia/issues/25227
446+
[#25402]: https://github.com/JuliaLang/julia/issues/25402

src/Compat.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,15 @@ end
10661066
export pushfirst!, popfirst!
10671067
end
10681068

1069+
# 0.7.0-DEV.3309
1070+
@static if VERSION < v"0.7.0-DEV.3309"
1071+
const IteratorSize = Base.iteratorsize
1072+
const IteratorEltype = Base.iteratoreltype
1073+
else
1074+
const IteratorSize = Base.IteratorSize
1075+
const IteratorEltype = Base.IteratorEltype
1076+
end
1077+
10691078
# 0.7.0-DEV.3173
10701079
@static if !isdefined(Base, :invpermute!)
10711080
const invpermute! = ipermute!

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,12 @@ let coolvec = [1,2,3]
10691069
@test popfirst!(coolvec) == 0
10701070
end
10711071

1072+
# 0.7.0-DEV.3309
1073+
let v = [1, 2, 3]
1074+
@test Compat.IteratorSize(v) == Base.HasShape()
1075+
@test Compat.IteratorEltype(v) == Base.HasEltype()
1076+
end
1077+
10721078
# 0.7.0-DEV.3057
10731079
let A = [0, 0, 0], B = [1, 2, 3]
10741080
@test copyto!(A, B) === A == B

0 commit comments

Comments
 (0)