LCOX calculation with strict enforcement of units#481
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #481 +/- ##
==========================================
- Coverage 87.04% 84.63% -2.41%
==========================================
Files 38 40 +2
Lines 3372 3468 +96
Branches 3372 3468 +96
==========================================
Hits 2935 2935
- Misses 250 346 +96
Partials 187 187 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
alexdewar
left a comment
There was a problem hiding this comment.
It seems like this approach could work and there would be definite advantages to doing things this way. My main concern is that we might end up wanting more arithmetic operations, but then again, they probably wouldn't be that hard to add and realistically we're not doing much in the way of fancy maths anyway, so even a fairly basic set of operations would probably do us fine.
I think you could simplify the use of the macros a bit.
unit_struct!(A)could also define multiplication ops forDimensionless(bothA * DimensionlessandDimensionless * A) and division ops- You could define a separate macro for creating units that are two other kinds of units divided together, e.g.
unit_div_struct!(A, B, APerB), which would also define operations likeA / B = APerBandB * APerB = Aetc.
That should make it more readable and easier to add new units (if we ever need to).
You could also define From<f64> for Dimensionless and vice versa as converting between these types is harmless (in contrast to other unit types).
Description
Please include a summary of the change and which issue is fixed (if any). Please also
include relevant motivation and context. List any dependencies that are required for
this change.
Type of change
Key checklist
$ cargo test$ cargo docFurther checks