Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
connorslade committed Nov 25, 2024
1 parent 4824840 commit c77380d
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 21 deletions.
5 changes: 1 addition & 4 deletions aoc_2021/src/day_08.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ fn parse(inp: &str) -> Vec<(Vec<String>, Vec<String>)> {
}

// Modified from https://stackoverflow.com/a/59939809/12471934
fn permutations<T: Clone>(items: Vec<T>) -> Vec<Vec<T>>
where
T: Ord,
{
fn permutations<T: Clone + Ord>(items: Vec<T>) -> Vec<Vec<T>> {
if items.len() == 1 {
return vec![items];
}
Expand Down
2 changes: 1 addition & 1 deletion aoc_2021/src/day_11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn tick_octopi(octopi: &mut Vec<Vec<Octopus>>, x: usize, y: usize) {
}
}

fn octo_neighbors(octopi: &Vec<Vec<Octopus>>, x: usize, y: usize) -> Vec<(usize, usize)> {
fn octo_neighbors(octopi: &[Vec<Octopus>], x: usize, y: usize) -> Vec<(usize, usize)> {
let mut out = Vec::new();
let (lenx, leny) = (octopi[0].len() as isize, octopi.len() as isize);
let (x, y) = (x as isize, y as isize);
Expand Down
1 change: 0 additions & 1 deletion aoc_2021/src/day_12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ fn parse(input: &str) -> ParseResult {

#[cfg(test)]
mod test {
use common::solution;
use indoc::indoc;

const CASE: &str = indoc! {"
Expand Down
1 change: 0 additions & 1 deletion aoc_2021/src/day_15.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ fn part_b(_input: &str) -> Answer {

#[cfg(test)]
mod test {
use common::solution;
use indoc::indoc;

const CASE: &str = indoc! {"
Expand Down
1 change: 0 additions & 1 deletion aoc_2022/src/day_16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ fn parse(input: &str) -> ParseResult {

#[cfg(test)]
mod test {
use common::solution;
use indoc::indoc;

const CASE: &str = indoc! {"
Expand Down
2 changes: 0 additions & 2 deletions aoc_2022/src/day_19.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ impl RobotType {
mod test {
use indoc::indoc;

use common::solution;

const CASE: &str = indoc! {"
Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian.
Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 3 ore and 12 obsidian.
Expand Down
1 change: 0 additions & 1 deletion aoc_2022/src/day_22.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ fn wrap_3d(world: &World, mut _pos: Point) -> Option<(Point, Direction)> {

#[cfg(test)]
mod test {
use common::solution;
use indoc::indoc;

const CASE: &str = indoc! {"
Expand Down
2 changes: 1 addition & 1 deletion aoc_2023/src/day_20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn parse_input(input: &str) -> HashMap<&str, Connection<'_>> {
_ => ConnectionType::Normal,
};

let source = source.trim_start_matches(|c| c == '%' || c == '&');
let source = source.trim_start_matches(['%', '&']);
out.insert(
source,
Connection {
Expand Down
2 changes: 1 addition & 1 deletion aoc_2023/src/day_22.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn solve(mut map: Vec<Box>, exhaustive: bool, count: fn(u32) -> u32) -> u32 {
out
}

fn shift_down(map: &mut Vec<Box>, exhaustive: bool) -> u32 {
fn shift_down(map: &mut [Box], exhaustive: bool) -> u32 {
let mut moved = HashSet::new();
let mut dirty = true;
while dirty {
Expand Down
18 changes: 10 additions & 8 deletions common/src/part.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::str::FromStr;
use std::{
fmt::{self, Display, Write},
str::FromStr,
};

#[derive(Debug, Clone, Copy)]
pub enum Part {
Expand All @@ -18,12 +21,11 @@ impl FromStr for Part {
}
}

impl ToString for Part {
fn to_string(&self) -> String {
match self {
Part::A => "a",
Part::B => "b",
}
.to_owned()
impl Display for Part {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_char(match self {
Part::A => 'a',
Part::B => 'b',
})
}
}

0 comments on commit c77380d

Please sign in to comment.