diff options
author | Andinus <andinus@nand.sh> | 2021-09-29 20:18:42 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-09-29 20:18:42 +0530 |
commit | 6cb0e630baeb9a5acddac65a627bd2f9bf291312 (patch) | |
tree | 9a95f52c2570b063a7cc40d30b883cbacc812b37 /rust/space-age/src | |
parent | b7f76db2a02aba793a68ba35c2b4b51d5e069bdc (diff) | |
download | exercism-6cb0e630baeb9a5acddac65a627bd2f9bf291312.tar.gz |
Rust: Space Age: Add exercise
Diffstat (limited to 'rust/space-age/src')
-rw-r--r-- | rust/space-age/src/lib.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/rust/space-age/src/lib.rs b/rust/space-age/src/lib.rs new file mode 100644 index 0000000..fec643f --- /dev/null +++ b/rust/space-age/src/lib.rs @@ -0,0 +1,35 @@ +#[derive(Debug)] +pub struct Duration; + +impl From<u64> for Duration { + fn from(s: u64) -> Self { + unimplemented!("s, measured in seconds: {}", s) + } +} + +pub trait Planet { + fn years_during(d: &Duration) -> f64 { + unimplemented!( + "convert a duration ({:?}) to the number of years on this planet for that duration", + d, + ); + } +} + +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 {} |