Pre-defined constants from all disciplines (math, physics, ...) as a Rust library.
Add this to your Cargo.toml file:
natural_constants = "0.2.0"
- math
- physics
- chemistry
- biology
- engineering
- conversion
It's far from complete. So if your favorite constant is missing, just let me know.
What should go in ? Everything that you think is useful. Some constants may fit into multiple modules - we then have to decide which one.
- Why are you using long names for the constants ? Why not a simple character like 'c' ?
Well simple characters are often used ("overloaded") by various constants, so to avoid ambiguity the full name is used.
- But isn't that too complicated to type ? Now my code looks too ugly!
Well no one stops you from doing s.th. like this:
use natural_constants::physics::*;
fn main() {
let c = speed_of_light_vac;
let m0 = 100.0;
// Use c in your code:
let E = m0 * c * c;
}
- What about pre-calculated stuff ?
Yes, why not ? If it's useful to you, it may also be useful to others.
This is an ongoing effort to make Rust more suitable for scientific / numeric computing, you can join the discussion here.