Apply clippy fixes
This commit is contained in:
parent
57abfe3195
commit
3eaea9577a
|
@ -8,8 +8,7 @@ const MAX_CALORY: usize = 30_000;
|
|||
|
||||
fn main() {
|
||||
let outfile = ::std::env::args()
|
||||
.skip(1)
|
||||
.next()
|
||||
.nth(1)
|
||||
.expect("Output file as first parameter");
|
||||
let mut outfile = BufWriter::new(File::create(outfile).expect("Can write outfile"));
|
||||
let mut rng = rand::thread_rng();
|
||||
|
|
|
@ -60,8 +60,7 @@ impl TopThree {
|
|||
|
||||
fn main() {
|
||||
let file = ::std::env::args()
|
||||
.skip(1)
|
||||
.next()
|
||||
.nth(1)
|
||||
.unwrap_or_else(|| String::from("./input"));
|
||||
let file = BufReader::new(File::open(file).expect("Input file not found"));
|
||||
let TopCal { top, .. } = file
|
||||
|
|
|
@ -6,8 +6,7 @@ const LINE_COUNT: usize = 20_000_000;
|
|||
|
||||
fn main() {
|
||||
let outfile = ::std::env::args()
|
||||
.skip(1)
|
||||
.next()
|
||||
.nth(1)
|
||||
.expect("Output file as first parameter");
|
||||
let mut outfile = BufWriter::new(File::create(outfile).expect("Can write outfile"));
|
||||
let mut rng = rand::thread_rng();
|
||||
|
|
|
@ -25,9 +25,9 @@ fn calculate_game_score(line: String) -> usize {
|
|||
// Rock -> 1
|
||||
// Paper -> 2
|
||||
// Scissor -> 3
|
||||
(0, 0) => 3 + 0,
|
||||
(1, 0) => 1 + 0,
|
||||
(2, 0) => 2 + 0,
|
||||
(0, 0) => 3,
|
||||
(1, 0) => 1,
|
||||
(2, 0) => 2,
|
||||
(0, 1) => 1 + 3,
|
||||
(1, 1) => 2 + 3,
|
||||
(2, 1) => 3 + 3,
|
||||
|
@ -40,8 +40,7 @@ fn calculate_game_score(line: String) -> usize {
|
|||
|
||||
fn main() {
|
||||
let file = ::std::env::args()
|
||||
.skip(1)
|
||||
.next()
|
||||
.nth(1)
|
||||
.unwrap_or_else(|| String::from("./input"));
|
||||
let file = BufReader::new(File::open(file).expect("Input file not found"));
|
||||
let sum: usize = file
|
||||
|
|
|
@ -20,7 +20,7 @@ use std::{
|
|||
};
|
||||
|
||||
lazy_static! {
|
||||
static ref CHARS: Vec<char> = ('a'..'z').chain('A'..'Z').collect();
|
||||
static ref CHARS: Vec<char> = ('a'..='z').chain('A'..='Z').collect();
|
||||
static ref ARGS: Args = Args::parse();
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ impl Args {
|
|||
}
|
||||
|
||||
fn replace_rand<I>(rng: &mut rand::rngs::SmallRng, list: &mut Vec<I>, item: I) {
|
||||
debug_assert!(list.len() > 0);
|
||||
debug_assert!(!list.is_empty());
|
||||
let idx = rng.gen_range(0..list.len());
|
||||
list[idx] = item;
|
||||
}
|
||||
|
@ -114,7 +114,6 @@ fn main() {
|
|||
let mut rng = SmallRng::from_rng(rand::thread_rng()).expect("Init rng");
|
||||
(0..ARGS.elf_groups)
|
||||
.flat_map(|_| gen_triple(&mut rng))
|
||||
.inspect(|line| debug_assert!(line.len() % 2 == 0))
|
||||
.for_each(|line| writeln!(outfile, "{line}").expect("Writing works"));
|
||||
outfile.flush().expect("Flushing works");
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ impl IsTrue for Assert<true> {}
|
|||
fn parse_chars<S: AsRef<str>>(line: S) -> Bitmask {
|
||||
line.as_ref()
|
||||
.as_bytes()
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(Bitmask::from_alpha)
|
||||
.reduce(std::ops::BitOr::bitor)
|
||||
.unwrap()
|
||||
|
|
|
@ -22,10 +22,10 @@ struct Counter {
|
|||
fn parse_line<S: AsRef<str>>(line: S) -> [RangeInclusive<usize>; 2] {
|
||||
let (first, second) = line
|
||||
.as_ref()
|
||||
.split_once(",")
|
||||
.split_once(',')
|
||||
.expect("A comma in every line");
|
||||
let (first_from, first_to) = first.split_once("-").expect("A range with a dash");
|
||||
let (second_from, second_to) = second.split_once("-").expect("A range with a dash");
|
||||
let (first_from, first_to) = first.split_once('-').expect("A range with a dash");
|
||||
let (second_from, second_to) = second.split_once('-').expect("A range with a dash");
|
||||
[
|
||||
first_from.parse().unwrap()..=first_to.parse().unwrap(),
|
||||
second_from.parse().unwrap()..=second_to.parse().unwrap(),
|
||||
|
|
|
@ -84,7 +84,7 @@ impl Port {
|
|||
self.columns[mv.to].extend(moved);
|
||||
}
|
||||
/// Read the letters on the top row of the container stacks.
|
||||
fn to_top_row_string(self) -> String {
|
||||
fn into_top_row_string(self) -> String {
|
||||
let bytes: Vec<u8> = self
|
||||
.columns
|
||||
.into_iter()
|
||||
|
@ -105,7 +105,7 @@ where
|
|||
.map(|line| line.parse())
|
||||
.map(Result::unwrap)
|
||||
.for_each(|mv| port.apply(mv, solve == SolvePuzzle::First));
|
||||
port.to_top_row_string()
|
||||
port.into_top_row_string()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -43,12 +43,9 @@ impl<Ext: CollectorExt> Collector<Ext> {
|
|||
self.change_director_root()
|
||||
} else if line == "$ cd .." {
|
||||
self.change_directory_up()
|
||||
} else if line.starts_with("$ cd ") {
|
||||
let target = &line[5..];
|
||||
} else if let Some(target) = line.strip_prefix("$ cd ") {
|
||||
self.change_directory_to(target)
|
||||
} else if line == "$ ls" {
|
||||
// Just ignore
|
||||
} else if line.starts_with("dir ") {
|
||||
} else if line == "$ ls" || line.starts_with("dir ") {
|
||||
// Nothing to do
|
||||
} else {
|
||||
let (size, _label) = line.split_once(' ').expect("A dir list entry");
|
||||
|
|
|
@ -166,7 +166,7 @@ fn print_scenic_view<R: BufRead>(reader: R) {
|
|||
.copied()
|
||||
.unwrap_or_default()
|
||||
+ 1;
|
||||
let sup = sup.checked_ilog2().unwrap_or_default();
|
||||
let _sup = sup.checked_ilog2().unwrap_or_default();
|
||||
for row_idx in 0..height {
|
||||
let output: String = (0..width)
|
||||
.map(|col_idx| {
|
||||
|
@ -177,7 +177,7 @@ fn print_scenic_view<R: BufRead>(reader: R) {
|
|||
visible_trees[row_idx][col_idx],
|
||||
)
|
||||
})
|
||||
.map(|(col_idx, tree, score, is_visible)| {
|
||||
.map(|(col_idx, tree, _score, is_visible)| {
|
||||
// let col = ::colorous::WARM.eval_rational(
|
||||
// score.checked_ilog2().unwrap_or_default() as usize,
|
||||
// sup as usize,
|
||||
|
|
Loading…
Reference in a new issue