-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
709 additions
and
637 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
rustbook-en/listings/ch09-error-handling/listing-09-13/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pub struct Guess { | ||
value: i32, | ||
} | ||
|
||
impl Guess { | ||
pub fn new(value: i32) -> Guess { | ||
if value < 1 || value > 100 { | ||
panic!("Guess value must be between 1 and 100, got {value}."); | ||
} | ||
|
||
Guess { value } | ||
} | ||
|
||
pub fn value(&self) -> i32 { | ||
self.value | ||
} | ||
} |
21 changes: 1 addition & 20 deletions
21
rustbook-en/listings/ch09-error-handling/listing-09-13/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.