Skip to content

Commit b5905fe

Browse files
pepijndevosKristofferC
authored andcommitted
Add missing type parameter to TakeWhile (#42958)
Without this `TakeWhile` has `eltype` of `Any` (cherry picked from commit ab0c6dd)
1 parent e6244c6 commit b5905fe

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

base/iterators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ end
779779

780780
IteratorSize(::Type{<:TakeWhile}) = SizeUnknown()
781781
eltype(::Type{TakeWhile{I,P}} where P) where {I} = eltype(I)
782-
IteratorEltype(::Type{TakeWhile{I}} where P) where {I} = IteratorEltype(I)
782+
IteratorEltype(::Type{TakeWhile{I, P}} where P) where {I} = IteratorEltype(I)
783783

784784

785785
# dropwhile

test/iterators.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ end
201201
@test collect(takewhile(_->true,5:10)) == 5:10
202202
@test collect(takewhile(isodd,[1,1,2,3])) == [1,1]
203203
@test collect(takewhile(<(2), takewhile(<(3), [1,1,2,3]))) == [1,1]
204+
@test Base.IteratorEltype(typeof(takewhile(<(4),Iterators.map(identity, 1:10)))) isa Base.EltypeUnknown
204205
end
205206

206207
# dropwhile
@@ -213,6 +214,7 @@ end
213214
@test isempty(dropwhile(_->true, 1:3))
214215
@test collect(dropwhile(isodd,[1,1,2,3])) == [2,3]
215216
@test collect(dropwhile(iseven,dropwhile(isodd,[1,1,2,3]))) == [3]
217+
@test Base.IteratorEltype(typeof(dropwhile(<(4),Iterators.map(identity, 1:10)))) isa Base.EltypeUnknown
216218
end
217219

218220
# cycle

0 commit comments

Comments
 (0)