From a7f2c6c964dcc24024d9f4e5938a4ff20e80f58a 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. --- Cargo.toml | 2 -- build.rs | 3 --- src/errors.rs | 17 ++++++++++------- src/lib.rs | 2 -- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c8b2cceea..864e7dfd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,6 @@ clear_on_drop = "=0.2.3" subtle = { version = "2", default-features = false } serde = { version = "1.0", default-features = false, optional = true } packed_simd = { version = "0.3.0", features = ["into_bits"], optional = true } -failure = { version = "0.1", optional = true } [build-dependencies] rand_core = { version = "0.3.0", default-features = false } @@ -61,7 +60,6 @@ clear_on_drop = "=0.2.3" subtle = { version = "2", default-features = false } serde = { version = "1.0", default-features = false, optional = true } packed_simd = { version = "0.3.0", features = ["into_bits"], optional = true } -failure = { version = "0.1", optional = true } [features] nightly = ["subtle/nightly", "clear_on_drop/nightly"] diff --git a/build.rs b/build.rs index d0913aa52..1cbb0cda7 100644 --- a/build.rs +++ b/build.rs @@ -17,9 +17,6 @@ extern crate subtle; #[cfg(all(feature = "nightly", feature = "packed_simd"))] extern crate packed_simd; -#[cfg(feature = "failure")] -extern crate failure; - use std::env; use std::fs::File; use std::io::Write; diff --git a/src/errors.rs b/src/errors.rs index d6f64c671..13a763871 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 4aa18f201..04da49a55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,8 +44,6 @@ extern crate packed_simd; extern crate byteorder; extern crate clear_on_drop; pub extern crate digest; -#[cfg(feature = "failure")] -extern crate failure; extern crate rand_core; #[cfg(all(test, feature = "stage2_build"))] extern crate rand_os;