diff --git a/exercises/structs/structs2.rs b/exercises/structs/structs2.rs index 328567f03..124933ba9 100644 --- a/exercises/structs/structs2.rs +++ b/exercises/structs/structs2.rs @@ -5,7 +5,6 @@ // Execute `rustlings hint structs2` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE #[derive(Debug)] struct Order { @@ -20,7 +19,7 @@ struct Order { fn create_order_template() -> Order { Order { - name: String::from("Bob"), + name: String::from("Hacker in Rust"), year: 2019, made_by_phone: false, made_by_mobile: false, @@ -38,7 +37,15 @@ mod tests { fn your_order() { let order_template = create_order_template(); // TODO: Create your own order using the update syntax and template above! - // let your_order = + let your_order = Order{ + name: String::from("Hacker in Rust"), + year: 2019, + made_by_phone: false, + made_by_mobile: false, + made_by_email: true, + item_number: 123, + count: 1, + }; assert_eq!(your_order.name, "Hacker in Rust"); assert_eq!(your_order.year, order_template.year); assert_eq!(your_order.made_by_phone, order_template.made_by_phone); diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index 4851317c5..6f63b62f2 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -7,8 +7,6 @@ // Execute `rustlings hint structs3` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE - #[derive(Debug)] struct Package { sender_country: String, @@ -29,12 +27,12 @@ impl Package { } } - fn is_international(&self) -> ??? { - // Something goes here... + fn is_international(&self) -> bool{ + self.sender_country != self.recipient_country } - fn get_fees(&self, cents_per_gram: i32) -> ??? { - // Something goes here... + fn get_fees(&self, cents_per_gram: i32) -> i32 { + cents_per_gram * self.weight_in_grams } }