1
0

switch to .as_bytes from .chars

This commit is contained in:
Ishan Jain 2022-12-02 12:36:40 +05:30
parent c658d2b1cf
commit 479bc36667
Signed by: ishan
GPG Key ID: 0506DB2A1CC75C27

View File

@ -8,19 +8,19 @@ const INPUTS: [&str; 2] = [
fn parse(input: &'static str) -> impl Iterator<Item = (Move, Outcome)> { fn parse(input: &'static str) -> impl Iterator<Item = (Move, Outcome)> {
input.trim().lines().map(|set| { input.trim().lines().map(|set| {
let mut set = set.chars(); let mut set = set.bytes();
let (a, b) = (set.next().unwrap(), set.nth(1).unwrap()); let (a, b) = (set.next().unwrap(), set.nth(1).unwrap());
let x = match a { let x = match a {
'A' => Move::Rock, b'A' => Move::Rock,
'B' => Move::Paper, b'B' => Move::Paper,
'C' => Move::Scissors, b'C' => Move::Scissors,
_ => unreachable!(), _ => unreachable!(),
}; };
let y = match b { let y = match b {
'X' => Outcome::X, b'X' => Outcome::X,
'Y' => Outcome::Y, b'Y' => Outcome::Y,
'Z' => Outcome::Z, b'Z' => Outcome::Z,
_ => unreachable!(), _ => unreachable!(),
}; };
(x, y) (x, y)