Comments (1)
Replying to @billyrieger in #126. I'd love to see a PR for this. If you want to start working through the open questions and put something together I'd be happy to provide assistance and review.
- Constants are definitely in-scope. I think I would prefer to see them under the
si
module rather than as a separate crate unless there is a noticeable compilation time change. I also think that a feature may be overkill unless there is a compilation time change. I haven't fully thought this through so I'm open to any suggestions. - I'm not sure the best way to handle support for non-float underlying storage types either. I've been punting on this issue (see #44) for a while now. Ideally the constants would actually be rust
const
by using<float literal> as V
, but that makes it impossible to create constants for the non built-in types (bigint
,ratio
, ...). Generallynum::FromPrimitive::from_f64
is used right now, but trait methods can't beconst
. - Also not sure the best location to place the constants. Using the
quantity!
macro? What about constants that belong to an unnamed quantity? Using thesystem!
macro? Both? Insi/mod.rs
? In aconstants
module undersi
? - For constants to include I'd go through the NIST list and include the most common. Just including everything isn't a big deal either.
- Use the constant symbol or the full constant name? Sort of leaning towards the full name.
Based on the limited time I spent thinking through the issue while replying below is one possible solution that is const
and works for all built-in types. Usage would be uom::si::constants::f32::G
.
pub mod constants {
storage_types! {
types: PrimInt, Float;
/// Gravitational constant.
pub const G: Quantity<uom::si::ISQ<P3, N1, N2, Z0, Z0, Z0, Z0>, uom::si::SI<f64>, f64> = Quantity { dimension: PhantomData, units: PhantomData, value: 6.674e-11 as V, };
}
}
from uom.
Related Issues (20)
- Unable to `clamp` quantity to a range. HOT 2
- Unexpected inequality with large conversion factor HOT 6
- Allow subtracting two thermodynamic temperatures HOT 3
- Deserialize references to quantities HOT 2
- New unit `ElectricalSusceptance` HOT 1
- Change of base_unit of Ratio quantity HOT 1
- Conversion to/from complex storage types is wrong
- Quantity-Aware access parts of quantity with complex storage type HOT 2
- Consider rust-specific cache action HOT 1
- Built-In SI system has no alias for Angular Momentum
- Unit conversion problem using BigRational
- Unclear about how to create arbitrary quantities with arbitrary units HOT 6
- Conversion to Watts HOT 1
- Newbie Feedback HOT 1
- New release HOT 1
- NIST Special Publication link
- Add a feature for bytemuck and/or zerocopy to `Quantity`
- Support fixed-point storage type(s)
- Better precision and abbreviation change for `astronomical_unit` HOT 6
- Implement clamp for f64 Quantities
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uom.