rangetools 0.1.4

Extending the Rust Range structs found in std::ops
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::{BoundedSet, RangeComplement, RangeIntersection, UnboundedSet};

impl<T> RangeComplement<UnboundedSet<T>> for BoundedSet<T>
where
    T: Copy + Ord,
{
    fn complement(self) -> UnboundedSet<T> {
        self.ranges
            .into_iter()
            .fold(UnboundedSet::Full, |acc, range| {
                acc.intersection(range.complement())
            })
    }
}