A lightweight, no_std Rust crate providing CODATA 2022 physical constants and IAU 2015 astronomical constants.
Familiar symbols are available in the aliases module.
use codata::aliases::{C, G_SI, G_CGS, AU, M_SUN};
fn main() {
println!("Speed of light: {} m/s", C);
println!("G (SI): {}", G_SI);
println!("G (CGS): {}", G_CGS);
println!("Solar Mass: {} kg", M_SUN);
}Search constants by their official NIST/IAU name.
use codata::find;
fn main() {
if let Some(c) = find("speed of light in vacuum") {
println!("Value: {} {}", c.value, c.unit);
}
}use codata::units::length::LIGHT_YEAR;
use codata::units::time::HOUR;
let dist_m = 5.0 * LIGHT_YEAR;
let duration_s = 2.0 * HOUR;- Physics: CODATA 2022 (NIST)
- Astronomy: Official IAU Resolutions (specifically 2012 B2 and 2015 B3).
MIT OR Apache-2.0