pub type Result = std::result::Result; #[derive(Debug)] pub enum Error { Io(std::io::Error), Utf8(std::str::Utf8Error), Opts(String), } impl std::error::Error for Error {} impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Error::Io(e) => write!(f, "cat: {}", e), Error::Utf8(e) => write!(f, "cat: {}", e), Error::Opts(s) => write!(f, "cat: unrecognized option '{}'", s), } } } impl From for Error { fn from(value: std::io::Error) -> Self { Error::Io(value) } } impl From for Error { fn from(value: std::str::Utf8Error) -> Self { Error::Utf8(value) } }