From 07f108e1d25da387735ce2ddca04a768a2739d9f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 5 Mar 2020 19:48:58 +0100 Subject: Replace failure with thiserror Signed-off-by: Matthias Beyer --- src/iter.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/iter.rs') diff --git a/src/iter.rs b/src/iter.rs index d3d8978..d776037 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -2,10 +2,9 @@ //! use chrono::NaiveDateTime; -use failure::Fallible as Result; -use failure::Error; -use error::ErrorKind as KEK; +use error::Result; +use error::Error; use timetype::TimeType; use matcher::Matcher; @@ -27,7 +26,7 @@ impl Iter { pub fn build(base: NaiveDateTime, inc: TimeType) -> Result { if !inc.is_a_amount() { - Err(Error::from(KEK::ArgumentErrorNotAnAmount(inc))) + Err(Error::ArgumentErrorNotAnAmount(inc)) } else { Ok(Iter { base: TimeType::moment(base), @@ -214,7 +213,7 @@ impl Iterator for UntilIter None } } else { - Some(Err(Error::from(KEK::ArgumentErrorNotAMoment(tt.name())))) + Some(Err(Error::ArgumentErrorNotAMoment(tt.name()))) } } } @@ -284,9 +283,8 @@ impl Times for I pub mod extensions { use timetype::TimeType as TT; use super::Iter; - use failure::Fallible as Result; - use failure::Error; - use error::ErrorKind as KEK; + use error::Result; + use error::Error; pub trait Minutely { fn minutely(self, i: i64) -> Result; @@ -325,7 +323,7 @@ pub mod extensions { assert!(increment.is_a_amount(), "This is a Bug, please report this!"); Iter::build(mom, increment) }, - _ => Err(Error::from(KEK::ArgumentErrorNotAnAmount(self))), + _ => Err(Error::ArgumentErrorNotAnAmount(self)), } } @@ -340,7 +338,7 @@ pub mod extensions { assert!(increment.is_a_amount(), "This is a Bug, please report this!"); Iter::build(mom, increment) }, - _ => Err(Error::from(KEK::ArgumentErrorNotAnAmount(self))), + _ => Err(Error::ArgumentErrorNotAnAmount(self)), } } @@ -355,7 +353,7 @@ pub mod extensions { assert!(increment.is_a_amount(), "This is a Bug, please report this!"); Iter::build(mom, increment) }, - _ => Err(Error::from(KEK::ArgumentErrorNotAnAmount(self))), + _ => Err(Error::ArgumentErrorNotAnAmount(self)), } } @@ -371,7 +369,7 @@ pub mod extensions { assert!(increment.is_a_amount(), "This is a Bug, please report this!"); Iter::build(mom, increment) }, - _ => Err(Error::from(KEK::ArgumentErrorNotAnAmount(self))), + _ => Err(Error::ArgumentErrorNotAnAmount(self)), } } @@ -386,7 +384,7 @@ pub mod extensions { assert!(increment.is_a_amount(), "This is a Bug, please report this!"); Iter::build(mom, increment) }, - _ => Err(Error::from(KEK::ArgumentErrorNotAnAmount(self))), + _ => Err(Error::ArgumentErrorNotAnAmount(self)), } } @@ -401,7 +399,7 @@ pub mod extensions { assert!(increment.is_a_amount(), "This is a Bug, please report this!"); Iter::build(mom, increment) }, - _ => Err(Error::from(KEK::ArgumentErrorNotAnAmount(self))), + _ => Err(Error::ArgumentErrorNotAnAmount(self)), } } @@ -412,7 +410,7 @@ pub mod extensions { fn every(self, inc: TT) -> Result { match self { TT::Moment(mom) => Iter::build(mom, inc), - _ => Err(Error::from(KEK::ArgumentErrorNotAnAmount(self))), + _ => Err(Error::ArgumentErrorNotAnAmount(self)), } } } -- cgit v1.2.3