diff --git a/src/inclusive_interval.rs b/src/inclusive_interval.rs index c9d4530..ab6458b 100644 --- a/src/inclusive_interval.rs +++ b/src/inclusive_interval.rs @@ -25,7 +25,7 @@ along with discrete_range_map. If not, see . //! yet. If you would still like the associated versions I would be happy to //! add them as well, just open a PR/Issue. -use core::ops::{Bound, RangeBounds}; +use core::ops::{Bound, Range, RangeBounds, RangeInclusive}; use serde::{Deserialize, Serialize}; @@ -115,6 +115,35 @@ where self.end } } +impl From> for RangeInclusive { + fn from(value: InclusiveInterval) -> Self { + value.start..=value.end + } +} +impl From> for InclusiveInterval +where + I: PointType, +{ + fn from(value: RangeInclusive) -> Self { + ii(*value.start(), *value.end()) + } +} +impl From> for Range +where + I: PointType, +{ + fn from(value: InclusiveInterval) -> Self { + value.start..value.end.up().unwrap() + } +} +impl From> for InclusiveInterval +where + I: PointType, +{ + fn from(value: Range) -> Self { + ie(value.start, value.end) + } +} /// Create an new Unbounded-Unbounded interval. ///