Skip to content

Commit eb29a36

Browse files
committed
Fix conversion to base type
1 parent d99febb commit eb29a36

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/utils.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ end
2525
return output
2626
end
2727

28-
Base.convert(::Type{Number}, q::AbstractQuantity) = q
28+
for (type, base_type, _) in ABSTRACT_QUANTITY_TYPES
29+
@eval Base.convert(::Type{$base_type}, q::$type) = q
30+
end
2931
function Base.convert(::Type{T}, q::UnionAbstractQuantity) where {T<:Number}
3032
@assert iszero(dimension(q)) "$(typeof(q)): $(q) has dimensions! Use `ustrip` instead."
3133
return convert(T, ustrip(q))

0 commit comments

Comments
 (0)