From 3dd9ceec1152d489bb72fbfbb506fc628baa1b1a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 8 Apr 2020 22:45:18 -0400 Subject: thiserror: replace usage of failure `thiserror` is much lighter and doesn't export a dependency on `failure` to consumers of the crate. --- Cargo.toml | 2 +- src/error.rs | 12 +++++++----- src/lib.rs | 5 ++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8f341bf..1f22f6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ keywords = ["vobject", "icalendar", "calendar", "contacts"] [dependencies] chrono = { version = "0.4", optional = true } -failure = "0.1" +thiserror = "1.0" [features] default = [] diff --git a/src/error.rs b/src/error.rs index 28f39e0..d98e716 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,16 +1,18 @@ -#[derive(Debug, Clone, Eq, PartialEq, Fail)] +use thiserror::Error; + +#[derive(Debug, Clone, Error)] pub enum VObjectErrorKind { - #[fail(display = "Parser error: {}", _0)] + #[error("Parser error: {}", _0)] ParserError(String), - #[fail(display = "Not a Vcard")] + #[error("Not a Vcard")] NotAVCard, - #[fail(display = "Not a Icalendar: {}", _0)] + #[error("Not a Icalendar: {}", _0)] NotAnICalendar(String), #[cfg(feature = "timeconversions")] - #[fail(display = "{}", _0)] + #[error("{}", _0)] ChronoError(::chrono::format::ParseError), } diff --git a/src/lib.rs b/src/lib.rs index 1aadb8e..4bd1193 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,8 @@ -#[macro_use] -extern crate failure; - #[cfg(feature = "timeconversions")] extern crate chrono; +extern crate thiserror; + #[macro_use] pub mod param; #[macro_use] mod util; -- cgit v1.2.3