summaryrefslogtreecommitdiff
path: root/exercises/error_handling/errors2.rs
diff options
context:
space:
mode:
authorRobert Fry <inbox@robertfry.xyz>2023-05-29 18:39:08 +0100
committerRobert Fry <inbox@robertfry.xyz>2023-05-29 18:41:51 +0100
commit7eef5d15eef780f93e22b1b4e0185f7708219ea0 (patch)
tree6c1f97594a23ba1eb870435ba1e81a652241db04 /exercises/error_handling/errors2.rs
parent30291a3c253f08a4191cfd544ba36867612ebb7a (diff)
docs: cleanup the explanation paragraphs at the start of each exercise.
Diffstat (limited to 'exercises/error_handling/errors2.rs')
-rw-r--r--exercises/error_handling/errors2.rs30
1 files changed, 16 insertions, 14 deletions
diff --git a/exercises/error_handling/errors2.rs b/exercises/error_handling/errors2.rs
index 6971fcf..d86f326 100644
--- a/exercises/error_handling/errors2.rs
+++ b/exercises/error_handling/errors2.rs
@@ -1,21 +1,23 @@
// errors2.rs
+//
// Say we're writing a game where you can buy items with tokens. All items cost
// 5 tokens, and whenever you purchase items there is a processing fee of 1
-// token. A player of the game will type in how many items they want to buy,
-// and the `total_cost` function will calculate the total cost of the tokens.
-// Since the player typed in the quantity, though, we get it as a string-- and
-// they might have typed anything, not just numbers!
-
+// token. A player of the game will type in how many items they want to buy, and
+// the `total_cost` function will calculate the total cost of the tokens. Since
+// the player typed in the quantity, though, we get it as a string-- and they
+// might have typed anything, not just numbers!
+//
// Right now, this function isn't handling the error case at all (and isn't
-// handling the success case properly either). What we want to do is:
-// if we call the `parse` function on a string that is not a number, that
-// function will return a `ParseIntError`, and in that case, we want to
-// immediately return that error from our function and not try to multiply
-// and add.
-
-// There are at least two ways to implement this that are both correct-- but
-// one is a lot shorter!
-// Execute `rustlings hint errors2` or use the `hint` watch subcommand for a hint.
+// handling the success case properly either). What we want to do is: if we call
+// the `parse` function on a string that is not a number, that function will
+// return a `ParseIntError`, and in that case, we want to immediately return
+// that error from our function and not try to multiply and add.
+//
+// There are at least two ways to implement this that are both correct-- but one
+// is a lot shorter!
+//
+// Execute `rustlings hint errors2` or use the `hint` watch subcommand for a
+// hint.
// I AM NOT DONE