switch to .as_bytes from .chars
This commit is contained in:
parent
c658d2b1cf
commit
479bc36667
14
src/main.rs
14
src/main.rs
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user