This commit is contained in:
aottolini 2023-01-09 19:26:42 -03:00
parent 5c8545edc7
commit 9bb57f5687
2 changed files with 9 additions and 14 deletions

View File

@ -1,11 +1,9 @@
// enums1.rs // enums1.rs
// No hints this time! ;) // No hints this time! ;)
// I AM NOT DONE
#[derive(Debug)] #[derive(Debug)]
enum Message { enum Message {
// TODO: define a few types of messages as used below Quit, Echo, Move, ChangeColor
} }
fn main() { fn main() {

View File

@ -4,13 +4,11 @@
// Make the code compile and the tests pass! // Make the code compile and the tests pass!
// Execute `rustlings hint structs3` or use the `hint` watch subcommand for a hint. // Execute `rustlings hint structs3` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
#[derive(Debug)] #[derive(Debug)]
struct Package { pub struct Package {
sender_country: String, pub sender_country: String,
recipient_country: String, pub recipient_country: String,
weight_in_grams: i32, pub weight_in_grams: i32,
} }
impl Package { impl Package {
@ -26,12 +24,12 @@ impl Package {
} }
} }
fn is_international(&self) -> ??? { fn is_international(&self) -> bool {
// Something goes here... &self.recipient_country != &self.sender_country
} }
fn get_fees(&self, cents_per_gram: i32) -> ??? { fn get_fees(&self, cents_per_gram: i32) -> i32 {
// Something goes here... &self.weight_in_grams * cents_per_gram
} }
} }
@ -54,7 +52,6 @@ mod tests {
let recipient_country = String::from("Russia"); let recipient_country = String::from("Russia");
let package = Package::new(sender_country, recipient_country, 1200); let package = Package::new(sender_country, recipient_country, 1200);
assert!(package.is_international()); assert!(package.is_international());
} }