12: Add solution to Rust track exercise "Space Age".
[?]
9Zb2bmkejrNknawUtr3MKvVstZkVDR8x8ritfgZXKrky
Dec 23, 2021, 5:34 PM
44WIYRRYXHTRYJGD3ISP4HWTYOTHO7TA4HG56OWFUVS7ESUTGKFACDependencies
- [2]
VXRUG63211: Add Rust track exercise "Space Age".
Change contents
- replacement in rust/space-age/src/lib.rs at line 5
pub struct Duration;pub struct Duration {seconds: f64,} - replacement in rust/space-age/src/lib.rs at line 10
fn from(s: u64) -> Self {unimplemented!("s, measured in seconds: {}", s)}fn from(s: u64) -> Self {Duration { seconds: s as f64 }} - replacement in rust/space-age/src/lib.rs at line 16
fn years_during(d: &Duration) -> f64 {unimplemented!("convert a duration ({:?}) to the number of years on this planet for that duration",d,);}fn years_during(d: &Duration) -> f64; - replacement in rust/space-age/src/lib.rs at line 19
pub struct Mercury;pub struct Venus;pub struct Earth;pub struct Mars;pub struct Jupiter;pub struct Saturn;pub struct Uranus;pub struct Neptune;macro_rules! impl_planets {($($planet:ident : $period:literal),*) => {$(pub struct $planet;impl Planet for $planet {fn years_during(d: &Duration) -> f64 {d.seconds / 31557600.0 / $period}})*};} - replacement in rust/space-age/src/lib.rs at line 30
impl Planet for Mercury {}impl Planet for Venus {}impl Planet for Earth {}impl Planet for Mars {}impl Planet for Jupiter {}impl Planet for Saturn {}impl Planet for Uranus {}impl Planet for Neptune {}[2.2297]impl_planets! {Mercury: 0.2408467,Venus: 0.61519726,Earth: 1.0,Mars: 1.8808158,Jupiter: 11.862615,Saturn: 29.447498,Uranus: 84.016846,Neptune: 164.79132}