File tree 2 files changed +13
-8
lines changed
2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 5
5
// Execute `rustlings hint structs2` or use the `hint` watch subcommand for a
6
6
// hint.
7
7
8
- // I AM NOT DONE
9
-
10
8
#[ derive( Debug ) ]
11
9
struct Order {
12
10
name : String ,
@@ -38,7 +36,11 @@ mod tests {
38
36
fn your_order ( ) {
39
37
let order_template = create_order_template ( ) ;
40
38
// TODO: Create your own order using the update syntax and template above!
41
- // let your_order =
39
+ let your_order = Order {
40
+ name : String :: from ( "Hacker in Rust" ) ,
41
+ count : 1 ,
42
+ ..order_template
43
+ } ;
42
44
assert_eq ! ( your_order. name, "Hacker in Rust" ) ;
43
45
assert_eq ! ( your_order. year, order_template. year) ;
44
46
assert_eq ! ( your_order. made_by_phone, order_template. made_by_phone) ;
Original file line number Diff line number Diff line change 7
7
// Execute `rustlings hint structs3` or use the `hint` watch subcommand for a
8
8
// hint.
9
9
10
- // I AM NOT DONE
11
-
12
10
#[ derive( Debug ) ]
13
11
struct Package {
14
12
sender_country : String ,
@@ -29,12 +27,17 @@ impl Package {
29
27
}
30
28
}
31
29
32
- fn is_international ( & self ) -> ??? {
30
+ fn is_international ( & self ) -> bool {
33
31
// Something goes here...
32
+ if self . sender_country == self . recipient_country {
33
+ false
34
+ } else {
35
+ true
36
+ }
34
37
}
35
38
36
- fn get_fees ( & self , cents_per_gram : i32 ) -> ??? {
37
- // Something goes here...
39
+ fn get_fees ( & self , cents_per_gram : i32 ) -> i32 {
40
+ self . weight_in_grams * cents_per_gram
38
41
}
39
42
}
40
43
You can’t perform that action at this time.
0 commit comments