pub fn cut<T: Ord + Clone>(region: Range<T>, exclude: Range<T>)
    -> Option<Cut<T>> {

    if overlaps(&region, &exclude) {
        let excluded =
            cmp::max(&region.start, &exclude.start).clone() ..
            cmp::min(&region.end, &exclude.end).clone();

        let before = (excluded.start > region.start)
            .then(|| region.start.clone() .. excluded.start.clone());

        let after = (region.end > excluded.end)
            .then(|| excluded.end.clone() .. region.end.clone());

        Some(Cut {
            before,
            excluded,
            after
        })
    } else {
        // non-overlapping
        None
    }
}
/// Cut a region out of another region, returning the portions of the original
/// `region` before and after as well as the region matching `exclude`.
Cut a region out of another region, returning the portions of the original
`region` before and after as well as the region matching `exclude`.
Cut a region out of another region returning the portions of the original ` region ` before and after as well as the region matching ` exclude ` .
pub fn cut<T: Ord + Clone>(region: Range<T>, exclude: Range<T>)
    -> Option<Cut<T>> {
    if overlaps(&region, &exclude) {
        let excluded =
            cmp::max(&region.start, &exclude.start).clone() ..
            cmp::min(&region.end, &exclude.end).clone();
        let before = (excluded.start > region.start)
            .then(|| region.start.clone() .. excluded.start.clone());
        let after = (region.end > excluded.end)
            .then(|| excluded.end.clone() .. region.end.clone());
        Some(Cut {
            before,
            excluded,
            after
        })
    } else {
        // non-overlapping
        None
    }
}
pub fn cut < T : Ord + Clone > ( region : Range < T > , exclude : Range < T > ) -> Option < Cut < T > > { if overlaps ( & region , & exclude ) { let excluded = cmp :: max ( & region . start , & exclude . start ) . clone ( ) .. cmp :: min ( & region . end , & exclude . end ) . clone ( ) ; let before = ( excluded . start > region . start ) . then ( | | region . start . clone ( ) .. excluded . start . clone ( ) ) ; let after = ( region . end > excluded . end ) . then ( | | excluded . end . clone ( ) .. region . end . clone ( ) ) ; Some ( Cut { before , excluded , after } ) } else { // non-overlapping None } }
Cut a region out of another region, returning the portions of the original
`region` before and after as well as the region matching `exclude`.
Cut a region out of another region returning the portions of the original ` region ` before and after as well as the region matching ` exclude ` .
region
Range<T>
exclude
Range<T>