diff --git a/src/main.rs b/src/main.rs index baf03c44501f145b360230a9e66b74f081a35dd8..55119f6393b65d51253a3edb15fe1d06f29ead97 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,10 +39,24 @@ fn main() { Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); + println!("Total number of attempts: {}", tries_counter); - for x in attempt_history { + for x in &attempt_history { println!("{:?}", x); } + + + println!("Getting the three last entries backwards from the HashMap.\n"); + println!("Attempt:Value"); + + for x in 0..3 { + if let Some(value) = attempt_history.get(&(tries_counter - x)) { + println!("{} : {}", tries_counter - x, value); + } else { + // Do nothing in case of error + } + } + println!( "Since the HashMap does not push things onto a heap like the Vec-type does, it will iterate over and print in the order items are found"