rangetools/implementations/union/
range_inclusive.rs

1use crate::{
2    BoundedSet, EmptyRange, LowerBoundedSet, RangeUnion, Rangetools, UnboundedRange, UnboundedSet,
3    UpperBoundedSet,
4};
5
6impl<T, R> RangeUnion<R, BoundedSet<T>> for std::ops::RangeInclusive<T>
7where
8    R: Rangetools<Set = BoundedSet<T>>,
9    T: Copy + Ord,
10{
11    type Output = BoundedSet<T>;
12    fn union(self, other: R) -> Self::Output {
13        RangeUnion::union(self.to_set(), other)
14    }
15}
16
17impl<T, R> RangeUnion<R, LowerBoundedSet<T>> for std::ops::RangeInclusive<T>
18where
19    R: Rangetools<Set = LowerBoundedSet<T>>,
20    T: Copy + Ord,
21{
22    type Output = LowerBoundedSet<T>;
23    fn union(self, other: R) -> Self::Output {
24        RangeUnion::union(self.to_set(), other)
25    }
26}
27
28impl<T, R> RangeUnion<R, UpperBoundedSet<T>> for std::ops::RangeInclusive<T>
29where
30    R: Rangetools<Set = UpperBoundedSet<T>>,
31    T: Copy + Ord,
32{
33    type Output = UpperBoundedSet<T>;
34    fn union(self, other: R) -> Self::Output {
35        RangeUnion::union(self.to_set(), other)
36    }
37}
38
39impl<T, R> RangeUnion<R, UnboundedSet<T>> for std::ops::RangeInclusive<T>
40where
41    R: Rangetools<Set = UnboundedSet<T>>,
42    T: Copy + Ord,
43{
44    type Output = UnboundedSet<T>;
45    fn union(self, other: R) -> Self::Output {
46        RangeUnion::union(self.to_set(), other)
47    }
48}
49
50impl<T, R> RangeUnion<R, UnboundedRange> for std::ops::RangeInclusive<T>
51where
52    R: Rangetools<Set = UnboundedRange>,
53    T: Copy + Ord,
54{
55    type Output = UnboundedRange;
56    fn union(self, other: R) -> Self::Output {
57        RangeUnion::union(other.to_set(), self)
58    }
59}
60
61impl<T, R> RangeUnion<R, EmptyRange<T>> for std::ops::RangeInclusive<T>
62where
63    R: Rangetools<Set = EmptyRange<T>>,
64    T: Copy + Ord,
65{
66    type Output = std::ops::RangeInclusive<T>;
67    fn union(self, other: R) -> Self::Output {
68        RangeUnion::union(other.to_set(), self)
69    }
70}