From f8ab92bf2665c0b1de951511f3a56bdcf4c648e2 Mon Sep 17 00:00:00 2001 From: Ishan Jain Date: Sun, 14 Jan 2024 03:48:25 +0530 Subject: [PATCH] clean it up a bit --- src/main.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 75984d8..8a2bae8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,14 +26,12 @@ fn main() { return None; } - let loc = if line[l - 6] == b';' { - l - 6 - } else if line[l - 5] == b';' { - l - 5 - } else if line[l - 4] == b';' { - l - 4 - } else { - unreachable!(); + let loc = match line[l - 6..][..3] { + [b';', _, _] => l - 6, + [_, b';', _] => l - 5, + [_, _, b';'] => l - 4, + + _ => unreachable!(), }; let (city, val) = line.split_at(loc);