diff --git a/listings/ch09-error-handling/listing-09-13/src/lib.rs b/listings/ch09-error-handling/listing-09-13/src/guessing_game.rs similarity index 100% rename from listings/ch09-error-handling/listing-09-13/src/lib.rs rename to listings/ch09-error-handling/listing-09-13/src/guessing_game.rs diff --git a/listings/ch09-error-handling/listing-09-13/src/main.rs b/listings/ch09-error-handling/listing-09-13/src/main.rs index cda389303b..6c3e963450 100644 --- a/listings/ch09-error-handling/listing-09-13/src/main.rs +++ b/listings/ch09-error-handling/listing-09-13/src/main.rs @@ -3,6 +3,8 @@ use rand::Rng; use std::cmp::Ordering; use std::io; +mod guessing_game; + fn main() { println!("Guess the number!"); diff --git a/src/ch09-03-to-panic-or-not-to-panic.md b/src/ch09-03-to-panic-or-not-to-panic.md index 66cba1fd81..58f2903bc5 100644 --- a/src/ch09-03-to-panic-or-not-to-panic.md +++ b/src/ch09-03-to-panic-or-not-to-panic.md @@ -159,23 +159,24 @@ program only operated on values between 1 and 100, and it had many functions with this requirement, having a check like this in every function would be tedious (and might impact performance). -Instead, we can make a new type and put the validations in a function to create -an instance of the type rather than repeating the validations everywhere. That -way, it’s safe for functions to use the new type in their signatures and -confidently use the values they receive. Listing 9-13 shows one way to define a -`Guess` type that will only create an instance of `Guess` if the `new` function -receives a value between 1 and 100. +Instead, we can make a new type in a dedicated module and put the validations in +a function to create an instance of the type rather than repeating the +validations everywhere. That way, it’s safe for functions to use the new type in +their signatures and confidently use the values they receive. Listing 9-13 shows +one way to define a `Guess` type that will only create an instance of `Guess` if +the `new` function receives a value between 1 and 100. -