Skip to content
Snippets Groups Projects
Commit 4e0598f9 authored by Henrik Tjäder's avatar Henrik Tjäder
Browse files

Implemented getting the last from the HashMap

parent a27bc1bf
No related branches found
No related tags found
No related merge requests found
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment