mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-21 21:42:23 -05:00
Improve a comment in errors2
This commit is contained in:
parent
248dd4415e
commit
d54c050985
2 changed files with 10 additions and 10 deletions
|
@ -5,11 +5,11 @@
|
||||||
// the player typed in the quantity, we get it as a string. They might have
|
// the player typed in the quantity, we get it as a string. They might have
|
||||||
// typed anything, not just numbers!
|
// typed anything, not just numbers!
|
||||||
//
|
//
|
||||||
// Right now, this function isn't handling the error case at all (and isn't
|
// Right now, this function isn't handling the error case at all. What we want
|
||||||
// handling the success case properly either). What we want to do is: If we call
|
// to do is: If we call the `total_cost` function on a string that is not a
|
||||||
// the `total_cost` function on a string that is not a number, that function
|
// number, that function will return a `ParseIntError`. In that case, we want to
|
||||||
// will return a `ParseIntError`. In that case, we want to immediately return
|
// immediately return that error from our function and not try to multiply and
|
||||||
// that error from our function and not try to multiply and add.
|
// add.
|
||||||
//
|
//
|
||||||
// There are at least two ways to implement this that are both correct. But one
|
// There are at least two ways to implement this that are both correct. But one
|
||||||
// is a lot shorter!
|
// is a lot shorter!
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
// the player typed in the quantity, we get it as a string. They might have
|
// the player typed in the quantity, we get it as a string. They might have
|
||||||
// typed anything, not just numbers!
|
// typed anything, not just numbers!
|
||||||
//
|
//
|
||||||
// Right now, this function isn't handling the error case at all (and isn't
|
// Right now, this function isn't handling the error case at all. What we want
|
||||||
// handling the success case properly either). What we want to do is: If we call
|
// to do is: If we call the `total_cost` function on a string that is not a
|
||||||
// the `total_cost` function on a string that is not a number, that function
|
// number, that function will return a `ParseIntError`. In that case, we want to
|
||||||
// will return a `ParseIntError`. In that case, we want to immediately return
|
// immediately return that error from our function and not try to multiply and
|
||||||
// that error from our function and not try to multiply and add.
|
// add.
|
||||||
//
|
//
|
||||||
// There are at least two ways to implement this that are both correct. But one
|
// There are at least two ways to implement this that are both correct. But one
|
||||||
// is a lot shorter!
|
// is a lot shorter!
|
||||||
|
|
Loading…
Reference in a new issue