Guest User

Untitled

a guest
Nov 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. use std::cmp::Ordering;
  2.  
  3. pub struct Guess {
  4. value: i32,
  5. }
  6.  
  7. impl Guess {
  8. pub fn new(value: i32) -> Guess {
  9. if value.cmp(&1) == Ordering::Less {
  10. panic!("Guess must be between 1 and 100, got {}.", value);
  11. }
  12.  
  13. if value.cmp(&100) == Ordering::Greater {
  14. panic!("Guess must be between 1 and 100, got {}.", value);
  15. }
  16.  
  17. Guess {
  18. value
  19. }
  20. }
  21.  
  22. pub fn value(&self) -> i32 {
  23. self.value
  24. }
  25. }
Add Comment
Please, Sign In to add comment