Fixed clippy warnings
This commit is contained in:
parent
c449b002f8
commit
331faaa44d
5 changed files with 12 additions and 14 deletions
|
@ -19,9 +19,9 @@ pub struct FileToBenchmark {
|
|||
expected_output: String,
|
||||
}
|
||||
|
||||
impl Into<(GivenDay, GivenTask, String)> for FileToBenchmark {
|
||||
fn into(self) -> (GivenDay, GivenTask, String) {
|
||||
(self.given_day, self.given_task, self.expected_output)
|
||||
impl From<FileToBenchmark> for (GivenDay, GivenTask, String) {
|
||||
fn from(val: FileToBenchmark) -> Self {
|
||||
(val.given_day, val.given_task, val.expected_output)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
let after_header = loaded
|
||||
loaded
|
||||
.into_iter()
|
||||
.map(|result| {
|
||||
vec![
|
||||
|
@ -50,6 +50,5 @@ pub fn create_rows_for_every_solutions(loaded: Vec<BenchmarkResult>) -> MatrixRe
|
|||
.unwrap_or_else(|| result.expected_output().to_string()),
|
||||
]
|
||||
})
|
||||
.collect();
|
||||
after_header
|
||||
.collect()
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ pub struct GivenDay(u32);
|
|||
|
||||
impl GivenDay {
|
||||
pub fn new(value: u32) -> Result<Self, InvalidGivenDayError> {
|
||||
if value < 1 || value > constants::MAX_DAY {
|
||||
Err(InvalidGivenDayError::InvalidRange(value))
|
||||
} else {
|
||||
if (1..=constants::MAX_DAY).contains(&value) {
|
||||
Ok(Self(value))
|
||||
} else {
|
||||
Err(InvalidGivenDayError::InvalidRange(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,10 @@ pub struct GivenTask(u32);
|
|||
|
||||
impl GivenTask {
|
||||
pub fn new(value: u32) -> Result<Self, InvalidGivenTaskError> {
|
||||
if value < 1 || value > constants::MAX_TASK {
|
||||
Err(InvalidGivenTaskError::InvalidRange(value))
|
||||
} else {
|
||||
if (1..=constants::MAX_TASK).contains(&value) {
|
||||
Ok(Self(value))
|
||||
} else {
|
||||
Err(InvalidGivenTaskError::InvalidRange(value))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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> {
|
||||
let content = if args.read_as_file() {
|
||||
let path = Path::new(args.input());
|
||||
let input_as_file = fs::read_to_string(path)?;
|
||||
input_as_file
|
||||
fs::read_to_string(path)?
|
||||
} else {
|
||||
args.input().to_string()
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue