🚀 Exploring the Solar System with Rust: Day 81-83 of #100daysofcode
Over the past three days, I've been juggling my exam preparations and my commitment to coding. Despite the time constraints, I managed to solve an intriguing problem from Exercism: calculating a person's age on different planets in our solar system, using Rust. 🌌
Here's a brief overview of the code:
1️⃣ Structs: I created structs for each planet - Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune.
2️⃣ Trait: I defined a trait, `Planet`, which includes two methods - `period` and `years_during`. The `period` method returns the orbital period of a planet in Earth years, and `years_during` calculates the age on the planet based on the duration in seconds.
3️⃣ Method Implementations: I implemented the `period` method for each planet, using the respective orbital period in Earth years.
4️⃣ Main Function: In the main function, I accept the user's age, convert it to seconds, and calculate the age on each planet using the `years_during` method.
This exercise allowed me to delve deeper into Rust's powerful features like structs, traits, and method implementations. It was a challenging yet rewarding experience, especially given the time management skills I had to employ due to my ongoing exams. 📚⏰
Here is the link to my code:- []
It took me three days, but the satisfaction of solving the problem and learning more about Rust was well worth the effort. Remember, it's not about how much time you have, it's about making the most of it! 💪
#rustlang #Exercism #CodingChallenge
Cool! But show us the code, or it didn’t happen. 😉