Fixed clippy warnings

This commit is contained in:
BoolPurist 2024-08-30 03:17:49 +02:00
parent c449b002f8
commit 331faaa44d
5 changed files with 12 additions and 14 deletions

View file

@ -19,9 +19,9 @@ pub struct FileToBenchmark {
expected_output: String, expected_output: String,
} }
impl Into<(GivenDay, GivenTask, String)> for FileToBenchmark { impl From<FileToBenchmark> for (GivenDay, GivenTask, String) {
fn into(self) -> (GivenDay, GivenTask, String) { fn from(val: FileToBenchmark) -> Self {
(self.given_day, self.given_task, self.expected_output) (val.given_day, val.given_task, val.expected_output)
} }
} }

View file

@ -36,7 +36,7 @@ pub fn create_average_row(average: Duration) -> std::iter::Once<Vec<String>> {
} }
pub fn create_rows_for_every_solutions(loaded: Vec<BenchmarkResult>) -> MatrixReport { pub fn create_rows_for_every_solutions(loaded: Vec<BenchmarkResult>) -> MatrixReport {
let after_header = loaded loaded
.into_iter() .into_iter()
.map(|result| { .map(|result| {
vec![ vec![
@ -50,6 +50,5 @@ pub fn create_rows_for_every_solutions(loaded: Vec<BenchmarkResult>) -> MatrixRe
.unwrap_or_else(|| result.expected_output().to_string()), .unwrap_or_else(|| result.expected_output().to_string()),
] ]
}) })
.collect(); .collect()
after_header
} }

View file

@ -22,10 +22,10 @@ pub struct GivenDay(u32);
impl GivenDay { impl GivenDay {
pub fn new(value: u32) -> Result<Self, InvalidGivenDayError> { pub fn new(value: u32) -> Result<Self, InvalidGivenDayError> {
if value < 1 || value > constants::MAX_DAY { if (1..=constants::MAX_DAY).contains(&value) {
Err(InvalidGivenDayError::InvalidRange(value))
} else {
Ok(Self(value)) Ok(Self(value))
} else {
Err(InvalidGivenDayError::InvalidRange(value))
} }
} }
} }

View file

@ -24,10 +24,10 @@ pub struct GivenTask(u32);
impl GivenTask { impl GivenTask {
pub fn new(value: u32) -> Result<Self, InvalidGivenTaskError> { pub fn new(value: u32) -> Result<Self, InvalidGivenTaskError> {
if value < 1 || value > constants::MAX_TASK { if (1..=constants::MAX_TASK).contains(&value) {
Err(InvalidGivenTaskError::InvalidRange(value))
} else {
Ok(Self(value)) Ok(Self(value))
} else {
Err(InvalidGivenTaskError::InvalidRange(value))
} }
} }
} }

View file

@ -32,8 +32,7 @@ pub fn solve_given_from_cli(args: &CliSolutionToSolve) -> AppResult<String> {
fn try_read_from_file_if_demanded(args: &CliSolutionToSolve) -> io::Result<String> { fn try_read_from_file_if_demanded(args: &CliSolutionToSolve) -> io::Result<String> {
let content = if args.read_as_file() { let content = if args.read_as_file() {
let path = Path::new(args.input()); let path = Path::new(args.input());
let input_as_file = fs::read_to_string(path)?; fs::read_to_string(path)?
input_as_file
} else { } else {
args.input().to_string() args.input().to_string()
}; };