fix some pedantic clippy lints that make sense

- clippy::redundant-closure-for-method-calls
- clippy::explicit-iter-loop
This commit is contained in:
Antoine Martin 2020-12-17 01:23:10 +01:00
parent 449cdc0157
commit e25bc47f8f
20 changed files with 59 additions and 66 deletions

View file

@ -8,10 +8,7 @@ const INPUT: &str = include_str!("../input/day02.txt");
pub fn run() -> Result<String> {
let mut res = String::with_capacity(128);
let presents: Vec<Present> = INPUT
.lines()
.map(|line| line.parse())
.collect::<Result<_>>()?;
let presents: Vec<Present> = INPUT.lines().map(str::parse).collect::<Result<_>>()?;
writeln!(res, "part 1: {}", part1(&presents))?;
writeln!(res, "part 2: {}", part2(&presents))?;
@ -104,7 +101,7 @@ mod tests {
fn part1_real() {
let presents: Vec<Present> = INPUT
.lines()
.map(|line| line.parse())
.map(str::parse)
.collect::<Result<_>>()
.unwrap();
@ -121,7 +118,7 @@ mod tests {
fn part2_real() {
let presents: Vec<Present> = INPUT
.lines()
.map(|line| line.parse())
.map(str::parse)
.collect::<Result<_>>()
.unwrap();

View file

@ -16,7 +16,7 @@ pub fn run() -> Result<String> {
fn part1(input: &str) -> usize {
input
.lines()
.map(|line| line.trim_end())
.map(str::trim_end)
.filter(|line| {
let mut vowel_count = 0;
for c in line.chars() {
@ -51,7 +51,7 @@ fn part1(input: &str) -> usize {
fn part2(input: &str) -> usize {
input
.lines()
.map(|line| line.trim_end())
.map(str::trim_end)
.filter(|line| {
for i in 0..(line.chars().count() - 3) {
let seq = &line[i..(i + 2)];