Skip to content

Commit a82e72e

Browse files
authored
Make parentindices return a Tuple (#11)
1 parent efad7bc commit a82e72e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/basic.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ end
2323
function Base.parentindices(x::MemoryView)
2424
elz = Base.elsize(x)
2525
if iszero(elz)
26-
1:(x.len)
26+
(1:(x.len),)
2727
else
2828
byte_offset = pointer(x.ref) - pointer(x.ref.mem)
2929
elem_offset = div(byte_offset % UInt, elz % UInt) % Int
30-
(elem_offset + 1):(elem_offset + x.len)
30+
((elem_offset + 1):(elem_offset + x.len),)
3131
end
3232
end
3333

3434
function Base.copy(x::MemoryView)
3535
isempty(x) && return x
36-
newmem = @inbounds x.ref.mem[parentindices(x)]
36+
newmem = @inbounds x.ref.mem[only(parentindices(x))]
3737
typeof(x)(unsafe, memoryref(newmem), x.len)
3838
end
3939

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,13 @@ end
306306

307307
@testset "Parentindices" begin
308308
mem = MemoryView(view(codeunits("lkdjfldfe"), 3:8))[2:6]
309-
@test parentindices(mem) == 4:8
309+
@test parentindices(mem) == (4:8,)
310310

311311
mem = MemoryView(UInt32[2, 5, 2, 1, 6, 8])[4:end]
312-
@test parentindices(mem) == 4:6
312+
@test parentindices(mem) == (4:6,)
313313

314314
mem = MemoryView(view(Vector{String}(undef, 10), 5:7))
315-
@test parentindices(mem) == 5:7
315+
@test parentindices(mem) == (5:7,)
316316
end
317317

318318
@testset "Similar and empty" begin

0 commit comments

Comments
 (0)