Switch to match and do cargo fmt
This commit is contained in:
parent
30aea9de13
commit
7b5d96c21e
|
@ -1,6 +1,6 @@
|
||||||
|
use std::collections::BinaryHeap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::{self, BufRead};
|
use std::io::{self, BufRead};
|
||||||
use std::collections::BinaryHeap;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let filename = "etc/p01.txt";
|
let filename = "etc/p01.txt";
|
||||||
|
@ -10,13 +10,20 @@ fn main() {
|
||||||
let mut heap = BinaryHeap::new();
|
let mut heap = BinaryHeap::new();
|
||||||
let mut cur_cals: u32 = 0;
|
let mut cur_cals: u32 = 0;
|
||||||
for l in lines {
|
for l in lines {
|
||||||
if let Ok(cals) = l.expect("Can't read line.").parse::<u32>() {
|
match l.expect("Can't read line.").parse::<u32>() {
|
||||||
cur_cals += cals;
|
Ok(cals) => {
|
||||||
} else {
|
cur_cals += cals;
|
||||||
heap.push(cur_cals);
|
}
|
||||||
println!("new cals: {}, max so far: {}", cur_cals, heap.peek().expect("Can't peek from heap!"));
|
_ => {
|
||||||
cur_cals = 0;
|
heap.push(cur_cals);
|
||||||
};
|
println!(
|
||||||
|
"new cals: {}, max so far: {}",
|
||||||
|
cur_cals,
|
||||||
|
heap.peek().expect("Can't peek from heap!")
|
||||||
|
);
|
||||||
|
cur_cals = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cur_cals > 0 {
|
if cur_cals > 0 {
|
||||||
|
|
Loading…
Reference in New Issue