mirror of https://github.com/KaiserY/trpl-zh-cn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
304 B
18 lines
304 B
1 year ago
|
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
|
||
|
}
|
||
|
}
|