Skip to content

Commit 1867b42

Browse files
authored
support slurping for svec (#43020)
It's an internal type, but this is occasionally useful (ref JuliaDebug/Cthulhu.jl#245).
1 parent 7ac710c commit 1867b42

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

base/tuple.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function rest end
133133
rest(t::Tuple) = t
134134
rest(t::Tuple, i::Int) = ntuple(x -> getfield(t, x+i-1), length(t)-i+1)
135135
rest(a::Array, i::Int=1) = a[i:end]
136+
rest(a::Core.SimpleVector, i::Int=1) = a[i:end]
136137
rest(itr, state...) = Iterators.rest(itr, state...)
137138

138139
# Use dispatch to avoid a branch in first

test/core.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7607,3 +7607,12 @@ end
76077607
@test !occursin(r"(interpreter|do_call)", trim_after_eval(string(stacktrace(btc, true))))
76087608
@test occursin(r"(interpreter|do_call)", trim_after_eval(string(stacktrace(bti, true))))
76097609
end
7610+
7611+
@testset "rest(svec, ...)" begin
7612+
x = Core.svec(1, 2, 3)
7613+
a..., = x
7614+
@test a == Core.svec(1, 2, 3)
7615+
a, b... = x
7616+
@test a == 1
7617+
@test b == Core.svec(2, 3)
7618+
end

0 commit comments

Comments
 (0)