Skip to content

Commit d374525

Browse files
authored
make the inner constructor an internal implementation detail (#36)
`AbstractArray` constructors that take `AbstractArray` usually copy the input array, something that our inner constructor doesn't do. So it seems safer to remove the inner constructor from our public API.
1 parent 4392680 commit d374525

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/FixedSizeArrays.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@ module FixedSizeArrays
22

33
export FixedSizeArray, FixedSizeVector, FixedSizeMatrix
44

5+
"""
6+
Internal()
7+
8+
Implementation detail. Do not use.
9+
"""
10+
struct Internal end
11+
512
struct FixedSizeArray{T,N} <: DenseArray{T,N}
613
mem::Memory{T}
714
size::NTuple{N,Int}
8-
function FixedSizeArray{T,N}(mem::Memory{T}, size::NTuple{N,Int}) where {T,N}
15+
function FixedSizeArray{T,N}(::Internal, mem::Memory{T}, size::NTuple{N,Int}) where {T,N}
916
new{T,N}(mem, size)
1017
end
1118
end
@@ -14,7 +21,7 @@ const FixedSizeVector{T} = FixedSizeArray{T,1}
1421
const FixedSizeMatrix{T} = FixedSizeArray{T,2}
1522

1623
function FixedSizeArray{T,N}(::UndefInitializer, size::NTuple{N,Int}) where {T,N}
17-
FixedSizeArray{T,N}(Memory{T}(undef, checked_dims(size)), size)
24+
FixedSizeArray{T,N}(Internal(), Memory{T}(undef, checked_dims(size)), size)
1825
end
1926
function FixedSizeArray{T,N}(::UndefInitializer, size::Vararg{Int,N}) where {T,N}
2027
FixedSizeArray{T,N}(undef, size)

0 commit comments

Comments
 (0)