use_astronomical_constants/
lib.rs1#![forbid(unsafe_code)]
2
3pub const ASTRONOMICAL_UNIT: f64 = 149_597_870_700.0;
7
8pub const LIGHT_YEAR: f64 = 9.460_730_472_580_8e15;
10
11pub const PARSEC: f64 = 3.085_677_581_491_367e16;
13
14pub const SOLAR_MASS: f64 = 1.988_47e30;
16
17#[cfg(test)]
18mod tests {
19 use super::{ASTRONOMICAL_UNIT, LIGHT_YEAR, PARSEC, SOLAR_MASS};
20
21 #[test]
22 fn larger_astronomical_distances_exceed_smaller_ones() {
23 assert!(LIGHT_YEAR > ASTRONOMICAL_UNIT);
24 assert!(PARSEC > LIGHT_YEAR);
25 }
26
27 #[test]
28 fn representative_stellar_mass_is_positive() {
29 assert!(SOLAR_MASS > 0.0);
30 }
31
32 #[test]
33 fn parsec_exceeds_astronomical_unit() {
34 assert!(PARSEC > ASTRONOMICAL_UNIT);
35 }
36}