Skip to content

Commit

Permalink
Fix Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
komu committed Nov 15, 2023
1 parent 5207dc7 commit a2b5e49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/bin/03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ impl Item {

impl From<char> 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)
Expand Down
13 changes: 5 additions & 8 deletions src/bin/22.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -234,10 +234,7 @@ fn example_wrap_definitions() -> Vec<WrapDefinition> {
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)),
]
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/bin/scaffold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
process,
};

const MODULE_TEMPLATE: &str = r###"pub fn part_one(input: &str) -> Option<u32> {
const MODULE_TEMPLATE: &str = r#"pub fn part_one(input: &str) -> Option<u32> {
None
}
Expand Down Expand Up @@ -38,7 +38,7 @@ mod tests {
assert_eq!(part_two(&input), None);
}
}
"###;
"#;

fn parse_args() -> Result<u8, pico_args::Error> {
let mut args = pico_args::Arguments::from_env();
Expand Down

0 comments on commit a2b5e49

Please sign in to comment.