Initialize src

This commit is contained in:
Yota Toyama
2019-04-13 20:22:56 +00:00
parent cf83be1d32
commit e620fbde57
5 changed files with 127 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
#[derive(Debug)]
pub struct Error {
description: &'static str,
}
impl Error {
pub fn new(description: &'static str) -> Error {
Error { description }
}
}
impl std::fmt::Display for Error {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(formatter, "{}", self.description)
}
}
impl std::error::Error for Error {
fn description(&self) -> &str {
self.description
}
}