| use std::cmp::Ordering; | |
| pub struct Guess { | |
| value: i32, | |
| } | |
| impl Guess { | |
| pub fn new(value: i32) -> Guess { | |
| if value.cmp(&1) == Ordering::Less { | |
| panic!("Guess must be between 1 and 100, got {}.", value); | |
| } | |
| if value.cmp(&100) == Ordering::Greater { | |
| panic!("Guess must be between 1 and 100, got {}.", value); | |
| } | |
| Guess { | |
| value | |
| } | |
| } | |
| pub fn value(&self) -> i32 { | |
| self.value | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment