diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-11-20 18:36:04 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2017-11-24 15:29:38 +0100 |
commit | 02939068e351ce5e37f5258c3ecb45480f3d3656 (patch) | |
tree | 00e1e91bf1d911719f0c9eccfd6589eba8b2fa16 /src/timetype.rs | |
parent | e8afcf56c124b228e4328760af6a7741b1bdd658 (diff) |
Add out of bounds check and error propagation for NaiveDate::from_ymd() calls
* Added recursion limit for error_chain
* Added new error for out-of-bounds error
* Added IntoTimeType helper trait
Diffstat (limited to 'src/timetype.rs')
-rw-r--r-- | src/timetype.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/timetype.rs b/src/timetype.rs index 6725edd..fa6fe11 100644 --- a/src/timetype.rs +++ b/src/timetype.rs @@ -438,6 +438,19 @@ impl TimeType { } +/// Helper trait for converting things into a TimeType object +/// +/// Until `TryInto` is stabilized in Rust, we need a helper trait for this. +pub trait IntoTimeType { + fn into_timetype(self) -> Result<TimeType>; +} + +impl IntoTimeType for TimeType { + fn into_timetype(self) -> Result<TimeType> { + Ok(self) + } +} + fn do_calculate(tt: TimeType) -> Result<TimeType> { use timetype::TimeType as TT; |