From c21224170a584a7a08b00f56e7b25f85a28a35c9 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Wed, 23 Oct 2019 21:32:27 +0000 Subject: [PATCH] Remove optional failure dependency and impl std::error::Error. --- src/errors.rs | 17 ++++++++++------- src/lib.rs | 2 -- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/errors.rs b/src/errors.rs index d6f64c6..13a7638 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -11,12 +11,15 @@ //! //! Currently, these are only used in the implementations of `TryFrom`. //! -//! This module optionally implements support for the types in the `failure` -//! crate. This can be enabled by building with `--features failure`. +//! If used with `std` support, this public types in this module implement the +//! `std::error::Error` trait. use core::fmt; use core::fmt::Display; +#[cfg(feature = "std")] +use std::error::Error; + /// Internal errors. Most application-level developers will likely not /// need to pay any attention to these. #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] @@ -41,8 +44,8 @@ impl Display for InternalError { } } -#[cfg(feature = "failure")] -impl ::failure::Fail for InternalError {} +#[cfg(feature = "std")] +impl Error for InternalError { } /// Errors which may occur. /// @@ -58,9 +61,9 @@ impl Display for CurveError { } } -#[cfg(feature = "failure")] -impl ::failure::Fail for CurveError { - fn cause(&self) -> Option<&dyn (::failure::Fail)> { +#[cfg(feature = "std")] +impl Error for CurveError { + fn source(&self) -> Option<&(dyn Error + 'static)> { Some(&self.0) } } diff --git a/src/lib.rs b/src/lib.rs index 5359b16..f9bb55d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,8 +43,6 @@ extern crate packed_simd; extern crate byteorder; pub extern crate digest; -#[cfg(feature = "failure")] -extern crate failure; extern crate rand_core; #[cfg(test)] extern crate rand_os;