refactor: remove failure and f64 for no_std

This commit is contained in:
jjy
2020-01-17 17:05:58 +08:00
parent 81843f5866
commit 1ae98055d0
3 changed files with 29 additions and 7 deletions
+19 -5
View File
@@ -1,12 +1,26 @@
pub use failure::Fail;
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Fail, Debug, PartialEq, Eq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Error {
#[fail(display = "Get root on an empty MMR")]
GetRootOnEmpty,
#[fail(display = "Inconsistent store")]
InconsistentStore,
#[fail(display = "Store error {}", _0)]
StoreError(crate::string::String),
}
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
use Error::*;
match self {
GetRootOnEmpty => write!(f, "Get root on an empty MMR")?,
InconsistentStore => write!(f, "Inconsistent store")?,
StoreError(msg) => write!(f, "Store error {}", msg)?,
}
Ok(())
}
}
cfg_if::cfg_if! {
if #[cfg(feature = "std")] {
impl ::std::error::Error for Error {}
}
}