Skip to content

Commit

Permalink
Defined ByCoordinate(x) and ByCoordinate(::Type) default implemen…
Browse files Browse the repository at this point in the history
…tations
  • Loading branch information
brainandforce committed Nov 29, 2023
1 parent 91a12ec commit 4889d2d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/traits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,16 @@ basis vectors describing the lattice in which the coordinate is contained.
"""
struct ByFractionalCoordinate{D} <: ByCoordinate{D}
end

"""
ByCoordinate(T::Type)
ByCoordinate(x) = ByCoordinate(typeof(x))
Returns a trait instance corresponding to the coordinate system associated with type `T` or an
instance of that type.
`ByCoordinate(x)` when `x` is not a `Type` calls `ByCoordinate(typeof(x))`. To implement the trait
for a custom type `T`, define `ByCoordinate(::Type{T}) where T`.
"""
ByCoordinate(x) = ByCoordinate(typeof(x))
ByCoordinate(::Type) = error("No coordinate trait is defined for this type.")

0 comments on commit 4889d2d

Please sign in to comment.