-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* @set SVector(tup) = ... * using instead of import * more general StaticArray signatures * remove redundant definitions of set() for invertible functions * splat(atan) * reorder * delete(first/last) on ranges * generalize norm setter * add hypot * add Pair setter * fix tests * insert and delete on cartesianindex * minor improvements * add Dates.value setter
- Loading branch information
Showing
8 changed files
with
76 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
module AccessorsStaticArraysExt | ||
isdefined(Base, :get_extension) ? (import StaticArrays) : (import ..StaticArrays) | ||
isdefined(Base, :get_extension) ? (using StaticArrays) : (using ..StaticArrays) | ||
using Accessors | ||
import Accessors: setindex, delete, insert | ||
|
||
@inline setindex(a::StaticArrays.StaticArray, args...) = Base.setindex(a, args...) | ||
@inline delete(obj::StaticArrays.SVector, l::IndexLens) = StaticArrays.deleteat(obj, only(l.indices)) | ||
@inline insert(obj::StaticArrays.SVector, l::IndexLens, val) = StaticArrays.insert(obj, only(l.indices), val) | ||
@inline setindex(a::StaticArray, args...) = Base.setindex(a, args...) | ||
@inline delete(obj::StaticVector, l::IndexLens) = StaticArrays.deleteat(obj, only(l.indices)) | ||
@inline insert(obj::StaticVector, l::IndexLens, val) = StaticArrays.insert(obj, only(l.indices), val) | ||
|
||
Accessors.set(obj::StaticArrays.SVector, ::Type{Tuple}, val::Tuple) = StaticArrays.SVector(val) | ||
Accessors.set(obj::StaticVector, ::Type{Tuple}, val::Tuple) = constructorof(typeof(obj))(val...) | ||
Accessors.set(obj::Tuple, ::Type{<:StaticVector}, val::StaticVector) = Tuple(val) | ||
|
||
Accessors.getall(obj::StaticArrays.StaticArray, ::Elements) = Tuple(obj) | ||
Accessors.setall(obj::StaticArrays.StaticArray, ::Elements, vs::AbstractArray) = constructorof(typeof(obj))(vs...) # just for disambiguation | ||
Accessors.setall(obj::StaticArrays.StaticArray, ::Elements, vs) = constructorof(typeof(obj))(vs...) | ||
Accessors.getall(obj::StaticArray, ::Elements) = Tuple(obj) | ||
Accessors.setall(obj::StaticArray, ::Elements, vs::AbstractArray) = constructorof(typeof(obj))(vs...) # just for disambiguation | ||
Accessors.setall(obj::StaticArray, ::Elements, vs) = constructorof(typeof(obj))(vs...) | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters