Skip to content

Commit

Permalink
update original
Browse files Browse the repository at this point in the history
  • Loading branch information
funkill committed May 29, 2024
1 parent 44b9a91 commit 66c0d0a
Show file tree
Hide file tree
Showing 12 changed files with 709 additions and 637 deletions.
17 changes: 17 additions & 0 deletions rustbook-en/listings/ch09-error-handling/listing-09-13/src/lib.rs
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
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
use guessing_game::Guess;
use rand::Rng;
use std::cmp::Ordering;
use std::io;

// ANCHOR: here
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
}
}
// ANCHOR_END: here

fn main() {
println!("Guess the number!");

Expand Down
Loading

0 comments on commit 66c0d0a

Please sign in to comment.