(rust) some more work on day 4 while on the bus

This commit is contained in:
kageru 2018-12-04 19:33:07 +01:00
parent eb46d6d2d8
commit 8bac0e4632
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -2,10 +2,9 @@
use std::{fs, cmp};
enum GuardAction {
shift_start(Guard),
shift_end(Guard),
fall_asleep,
wake_up,
BeginShift(i32),
FallAsleep,
WakeUp,
}
struct Guard {
@ -75,7 +74,16 @@ impl Event {
}
fn parse_action(input: &String) -> GuardAction {
return GuardAction::fall_asleep;
match input[0] {
"f" => GuardAction::FallAsleep,
"w" => GuardAction::WakeUp,
"G" => {
let gid: i32;
scan!(input.bytes() => "Guard #{} begins shift", gid);
GuardAction::BeginShift(gid)
}
_ => // undefined?
}
}
fn event_from_line(line: &String) -> Event {