Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/FixedSizeArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ end

Base.IndexStyle(::Type{<:FixedSizeArray}) = IndexLinear()
Base.@propagate_inbounds Base.getindex(A::FixedSizeArray, i::Int) = A.mem[i]
Base.@propagate_inbounds Base.setindex!(A::FixedSizeArray, v, i::Int) = A.mem[i] = v
Base.@propagate_inbounds Base.@assume_effects :noub_if_noinbounds function Base.setindex!(A::FixedSizeArray{T}, x, i::Int) where {T}
@boundscheck checkbounds(A, i)
@inbounds A.mem[i] = x
return A
end

Base.size(a::FixedSizeArray) = a.size

Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ end
end
end

@testset "setindex!" begin
v = FSV{Float64}(undef, 2)
v[1] = 1
v[2] = 2
@test v[1] == 1
@test v[2] == 2
@test_throws BoundsError v[3] = 3
end

@testset "FixedSizeVector" begin
v = FSV{Float64}(undef, 3)
@test length(v) == 3
Expand Down