-
Notifications
You must be signed in to change notification settings - Fork 121
Open
Description
Declaring a Unitful unit in a struct could be made nicer, if the following function quantity(..) is provided in Unitful:
using Unitful
# The following function should be defined inside Unitful
quantity(FloatType, unit) = Quantity{FloatType, dimension(unit), typeof(unit)}
mutable struct Data{FloatType <: AbstractFloat}
length::quantity(FloatType, u"m")
end
L = Data{Float64}(2.0u"mm")
@show L
Of course, it is easy to introduce such a function in an own package. However, it would be better if this feature is directly provided by Unitful.
bhalonen
Metadata
Metadata
Assignees
Labels
No labels