2020 day 13 Cleanup: Removed superfluous Error Type
This commit is contained in:
parent
711fed5cac
commit
1e610ae6dc
1 changed files with 0 additions and 22 deletions
|
@ -1,27 +1,5 @@
|
||||||
use core::fmt::Display;
|
|
||||||
use std::num::ParseIntError;
|
use std::num::ParseIntError;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
|
||||||
pub enum ParseError {
|
|
||||||
ParseIntError(std::num::ParseIntError),
|
|
||||||
LineMalformed(String),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ParseIntError> for ParseError {
|
|
||||||
fn from(value: ParseIntError) -> Self {
|
|
||||||
Self::ParseIntError(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for ParseError {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
Self::ParseIntError(e) => write!(f, "Unable to parse into integer: {e}"),
|
|
||||||
Self::LineMalformed(v) => write!(f, "Line is malformed: {v}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn run(input: &str) -> Result<(usize, usize), ParseIntError> {
|
pub fn run(input: &str) -> Result<(usize, usize), ParseIntError> {
|
||||||
let mut lines = input.lines();
|
let mut lines = input.lines();
|
||||||
let earliest_arrival = lines.next().expect("Input was empty").parse::<usize>()?;
|
let earliest_arrival = lines.next().expect("Input was empty").parse::<usize>()?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue