impl Clone and Display for CatboxError

This commit is contained in:
Yash Karandikar 2022-06-21 15:35:56 +05:30
parent fbf2532189
commit 0d32a3d9ec

View file

@ -145,7 +145,7 @@ macro_rules! error_from_format {
}; };
} }
#[derive(Debug)] #[derive(Clone, Debug)]
pub struct CatboxError(String); pub struct CatboxError(String);
impl From<String> for CatboxError { impl From<String> for CatboxError {
@ -162,6 +162,12 @@ error_from_format! {
InitError InitError
} }
impl std::fmt::Display for CatboxError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
pub type Result<T> = std::result::Result<T, CatboxError>; pub type Result<T> = std::result::Result<T, CatboxError>;
/// Wrapper type around SDL's [`EventPump`](sdl2::EventPump). See those docs for more info. /// Wrapper type around SDL's [`EventPump`](sdl2::EventPump). See those docs for more info.