File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 99// Execute `rustlings hint errors1` or use the `hint` watch subcommand for a
1010// hint.
1111
12- // I AM NOT DONE
1312
14- pub fn generate_nametag_text ( name : String ) -> Option < String > {
13+
14+ pub fn generate_nametag_text ( name : String ) -> Result < String , String > {
1515 if name. is_empty ( ) {
1616 // Empty names aren't allowed.
17- None
17+ Err ( "`name` was empty; it must be nonempty." . into ( ) )
1818 } else {
19- Some ( format ! ( "Hi! My name is {}" , name) )
19+ Ok ( format ! ( "Hi! My name is {}" , name) )
2020 }
2121}
2222
Original file line number Diff line number Diff line change 1919// Execute `rustlings hint errors2` or use the `hint` watch subcommand for a
2020// hint.
2121
22- // I AM NOT DONE
22+
2323
2424use std:: num:: ParseIntError ;
2525
2626pub fn total_cost ( item_quantity : & str ) -> Result < i32 , ParseIntError > {
2727 let processing_fee = 1 ;
2828 let cost_per_item = 5 ;
29- let qty = item_quantity. parse :: < i32 > ( ) ;
29+ let qty = item_quantity. parse :: < i32 > ( ) ? ;
3030
3131 Ok ( qty * cost_per_item + processing_fee)
3232}
You can’t perform that action at this time.
0 commit comments