paholg / dimensioned

Compile-time dimensional analysis for various unit systems using Rust's type system.
https://crates.io/crates/dimensioned
MIT License
300 stars 23 forks source link

Implement `max` and `min` functions for primitive types that have them #83

Open quentinmit opened 2 years ago

quentinmit commented 2 years ago

f32, f64, etc. have functions called max and min that are defined to return the higher/lower non-NaN number. AFAICT it's not possible to actually call them on unit types without manually unpacking with either .value_raw or creating a dimensionless quantity and derefing. Please consider adding max and min functions on the unit types if the primitive type has them.

v-morlock commented 9 months ago

It would be great to also implement sin / cos / ... to make calculations with units easier. Right now, we have to do a lot of manual unpacking to do any meaningful calculations with units..