summaryrefslogtreecommitdiffstats
path: root/src/timetype.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-11-20 18:36:04 +0100
committerMatthias Beyer <mail@beyermatthias.de>2017-11-24 15:29:38 +0100
commit02939068e351ce5e37f5258c3ecb45480f3d3656 (patch)
tree00e1e91bf1d911719f0c9eccfd6589eba8b2fa16 /src/timetype.rs
parente8afcf56c124b228e4328760af6a7741b1bdd658 (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.rs13
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;