pub fn union(&self, other: &Range<T>) -> Option<Range<T>> {
        if self.is_empty() {
            return Some(other.clone());
        }

        if other.is_empty() {
            return Some(self.clone());
        }

        let (OptBound(l_lower), OptBound(u_lower)) = order(OptBound(self.lower()), OptBound(other.lower()));
        let (OptBound(l_upper), OptBound(u_upper)) = order(OptBound(self.upper()), OptBound(other.upper()));

        let discontiguous = match (u_lower, l_upper) {
            (
                Some(&RangeBound {
                    value: ref l,
                    type_: Exclusive,
                    ..
                }),
                Some(&RangeBound {
                    value: ref u,
                    type_: Exclusive,
                    ..
                }),
            ) => l >= u,
            (Some(&RangeBound { value: ref l, .. }), Some(&RangeBound { value: ref u, .. })) => l > u,
            _ => false,
        };

        if discontiguous {
            None
        } else {
            Some(Range::new(
                l_lower.cloned(),
                u_upper.cloned(),
            ))
        }
    }
/// Returns the union of this range with another if it is contiguous.
Returns the union of this range with another if it is contiguous.
Returns the union of this range with another if it is contiguous .
pub fn union(&self, other: &Range<T>) -> Option<Range<T>> {
        if self.is_empty() {
            return Some(other.clone());
        }
        if other.is_empty() {
            return Some(self.clone());
        }
        let (OptBound(l_lower), OptBound(u_lower)) = order(OptBound(self.lower()), OptBound(other.lower()));
        let (OptBound(l_upper), OptBound(u_upper)) = order(OptBound(self.upper()), OptBound(other.upper()));
        let discontiguous = match (u_lower, l_upper) {
            (
                Some(&RangeBound {
                    value: ref l,
                    type_: Exclusive,
                    ..
                }),
                Some(&RangeBound {
                    value: ref u,
                    type_: Exclusive,
                    ..
                }),
            ) => l >= u,
            (Some(&RangeBound { value: ref l, .. }), Some(&RangeBound { value: ref u, .. })) => l > u,
            _ => false,
        };
        if discontiguous {
            None
        } else {
            Some(Range::new(
                l_lower.cloned(),
                u_upper.cloned(),
            ))
        }
    }
pub fn union ( & self , other : & Range < T > ) -> Option < Range < T > > { if self . is_empty ( ) { return Some ( other . clone ( ) ) ; } if other . is_empty ( ) { return Some ( self . clone ( ) ) ; } let ( OptBound ( l_lower ) , OptBound ( u_lower ) ) = order ( OptBound ( self . lower ( ) ) , OptBound ( other . lower ( ) ) ) ; let ( OptBound ( l_upper ) , OptBound ( u_upper ) ) = order ( OptBound ( self . upper ( ) ) , OptBound ( other . upper ( ) ) ) ; let discontiguous = match ( u_lower , l_upper ) { ( Some ( & RangeBound { value : ref l , type_ : Exclusive , .. } ) , Some ( & RangeBound { value : ref u , type_ : Exclusive , .. } ) , ) => l >= u , ( Some ( & RangeBound { value : ref l , .. } ) , Some ( & RangeBound { value : ref u , .. } ) ) => l > u , _ => false , } ; if discontiguous { None } else { Some ( Range :: new ( l_lower . cloned ( ) , u_upper . cloned ( ) , ) ) } }
Returns the union of this range with another if it is contiguous.
Returns the union of this range with another if it is contiguous .
&self
other
&Range<T>
&self
other
&Range<T>