diff --git a/src/bin/03.rs b/src/bin/03.rs index 3d6d840..7cf98bf 100644 --- a/src/bin/03.rs +++ b/src/bin/03.rs @@ -103,9 +103,9 @@ impl Item { impl From for Item { fn from(c: char) -> Self { - if ('a'..='z').contains(&c) { + if c.is_ascii_lowercase() { Item((c as u8) - b'a' + 1) - } else if ('A'..='Z').contains(&c) { + } else if c.is_ascii_uppercase() { Item((c as u8) - b'A' + 27) } else { panic!("unexpected char '{}'", c) diff --git a/src/bin/22.rs b/src/bin/22.rs index 13bc80e..5d6c57b 100644 --- a/src/bin/22.rs +++ b/src/bin/22.rs @@ -100,10 +100,10 @@ fn map_point((a1, _a2): (Point, Point), (b1, b2): (Point, Point), p: Point) -> P let b_dx = (b2.x - b1.x).signum(); let b_dy = (b2.y - b1.y).signum(); - return Point { + Point { x: b1.x + d * b_dx, y: b1.y + d * b_dy, - }; + } } #[derive(Clone, Copy)] @@ -234,10 +234,7 @@ fn example_wrap_definitions() -> Vec { Boundary::bottom(8, 12, len), Boundary::bottom(0, 8, len).reverse(), ), - WrapDefinition::new( - Boundary::top(4, 4, len), - Boundary::left(8, 0, len), - ), + WrapDefinition::new(Boundary::top(4, 4, len), Boundary::left(8, 0, len)), ] } @@ -294,7 +291,7 @@ impl WrapStrategy { let (dx, dy) = facing.deltas(); p = p.towards(dx, dy); } - return (p, facing); + (p, facing) } WrapStrategy::Complex(wraps) => { for wrap in wraps { @@ -390,7 +387,7 @@ impl<'a> MonkeyMap<'a> { mut p: Point, mut facing: Facing, wrap_strategy: &WrapStrategy, - ) -> Option<(Point, Facing)> { + ) -> Option<(Point, Facing)> { let (dx, dy) = facing.deltas(); p = p.towards(dx, dy); diff --git a/src/bin/scaffold.rs b/src/bin/scaffold.rs index 89d4bd3..c10ca61 100644 --- a/src/bin/scaffold.rs +++ b/src/bin/scaffold.rs @@ -8,7 +8,7 @@ use std::{ process, }; -const MODULE_TEMPLATE: &str = r###"pub fn part_one(input: &str) -> Option { +const MODULE_TEMPLATE: &str = r#"pub fn part_one(input: &str) -> Option { None } @@ -38,7 +38,7 @@ mod tests { assert_eq!(part_two(&input), None); } } -"###; +"#; fn parse_args() -> Result { let mut args = pico_args::Arguments::from_env();