Skip to content

Commit

Permalink
Fix lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
maneatingape committed May 18, 2024
1 parent 4dfb133 commit 1b240a6
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions benches/benchmark.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(unstable_features)]
#![feature(test)]
extern crate test;

Expand Down
26 changes: 14 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,22 @@ fn main() {
for Solution { year, day, wrapper } in &solutions {
let path: PathBuf =
["input", &format!("year{year}"), &format!("day{day:02}.txt")].iter().collect();
let Ok(data) = read_to_string(&path) else {
eprintln!("Place input file in {path:?}");
continue;
};

let time = Instant::now();
let (answer1, answer2) = wrapper(&data);
let duration = time.elapsed().as_micros();
elapsed += time.elapsed();
if let Ok(data) = read_to_string(&path) {
let time = Instant::now();
let (answer1, answer2) = wrapper(&data);
let duration = time.elapsed().as_micros();
elapsed += time.elapsed();

println!("{BOLD}{YELLOW}{year} Day {day:02}{RESET}");
println!(" Part 1: {answer1}");
println!(" Part 2: {answer2}");
println!(" Duration: {duration} μs");
println!("{BOLD}{YELLOW}{year} Day {day:02}{RESET}");
println!(" Part 1: {answer1}");
println!(" Part 2: {answer2}");
println!(" Duration: {duration} μs");
} else {
eprintln!("{BOLD}{RED}{year} Day {day:02}{RESET}");
eprintln!(" Missing input!");
eprintln!(" Place input file in {BOLD}{WHITE}{}{RESET}", path.display());
}
}

// Print totals
Expand Down
2 changes: 1 addition & 1 deletion src/year2015/day04.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Shared {

pub fn parse(input: &str) -> Shared {
let shared = Shared {
prefix: input.trim().to_string(),
prefix: input.trim().to_owned(),
done: AtomicBool::new(false),
counter: AtomicU32::new(1000),
first: AtomicU32::new(u32::MAX),
Expand Down
2 changes: 1 addition & 1 deletion src/year2016/day05.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Exclusive {

pub fn parse(input: &str) -> Vec<u32> {
let shared = Shared {
prefix: input.trim().to_string(),
prefix: input.trim().to_owned(),
done: AtomicBool::new(false),
counter: AtomicU32::new(1000),
};
Expand Down
4 changes: 2 additions & 2 deletions src/year2016/day17.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pub fn parse(input: &str) -> State {
state
}

pub fn part1(input: &State) -> String {
input.min.to_string()
pub fn part1(input: &State) -> &str {
&input.min
}

pub fn part2(input: &State) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion src/year2017/day14.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Exclusive {

/// Parallelize the hashing as each row is independent.
pub fn parse(input: &str) -> Vec<u8> {
let shared = Shared { prefix: input.trim().to_string(), counter: AtomicUsize::new(0) };
let shared = Shared { prefix: input.trim().to_owned(), counter: AtomicUsize::new(0) };
let exclusive = Exclusive { grid: vec![0; 0x4000] };
let mutex = Mutex::new(exclusive);

Expand Down
2 changes: 1 addition & 1 deletion src/year2019/day13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn draw(tiles: &[i64], score: i64, blocks: i64) {

for y in 0..20 {
for x in 0..44 {
let _ = match tiles[44 * y + x] {
let _unused = match tiles[44 * y + x] {
0 => write!(s, " "),
1 if y == 0 => write!(s, "{GREEN}_{RESET}"),
1 => write!(s, "{GREEN}|{RESET}"),
Expand Down

0 comments on commit 1b240a6

Please sign in to comment.