Space Age
https://exercism.org/tracks/rust/exercises/space-age
条件
初期コード
#[derive(Debug)]pub struct Duration;
impl From<u64> for Duration { fn from(s: u64) -> Self { todo!("s, measured in seconds: {s}") }}
pub trait Planet { fn years_during(d: &Duration) -> f64 { todo!("convert a duration ({d:?}) to the number of years on this planet for that duration"); }}
pub struct Mercury;pub struct Venus;pub struct Earth;pub struct Mars;pub struct Jupiter;pub struct Saturn;pub struct Uranus;pub struct Neptune;
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 {}考察
メモ
impl Fromについて- そもそも
traitとは?