Adds Day1
This commit is contained in:
28
src/error/mod.rs
Normal file
28
src/error/mod.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use std::{num::{ParseIntError, TryFromIntError}, convert::Infallible, io};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AdventError(pub String);
|
||||
|
||||
impl From<ParseIntError> for AdventError {
|
||||
fn from(e: ParseIntError) -> Self {
|
||||
AdventError(e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<io::Error> for AdventError {
|
||||
fn from(e: io::Error) -> Self {
|
||||
AdventError(e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Infallible> for AdventError {
|
||||
fn from(_: Infallible) -> Self {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TryFromIntError> for AdventError {
|
||||
fn from(e: TryFromIntError) -> Self {
|
||||
AdventError(e.to_string())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user