Skip to content

Commit 2e75cfe

Browse files
Define adapt_structure for CartesianIndices
1 parent c80a6ac commit 2e75cfe

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/base.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,7 @@ adapt_structure(to, r::Base.Slice) = Base.Slice(adapt(to, r.indices))
8383

8484
adapt_structure(to, r::LinRange) =
8585
LinRange(adapt(to, r.start), adapt(to, r.stop), r.len)
86+
87+
## CartesianIndices
88+
89+
adapt_structure(to, ci::CartesianIndices) = ci

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,7 @@ end
255255
@test adapt(Array, Base.Slice(1:10)) === Base.Slice(1:10)
256256
@test adapt(Array, LinRange(1,2,10)) === LinRange(1,2,10)
257257
end
258+
259+
@testset "CartesianIndices" begin
260+
@test adapt(Array, CartesianIndices((1,2,3))) === CartesianIndices((1,2,3))
261+
end

0 commit comments

Comments
 (0)