/**
    Converts two intervals into their intersection.

    # Example

    ```
    use advanced_collections::interval::Interval;
    fn main() {
       let a = Interval::closed(2,5);
       let b = Interval::closed(3,6);
       assert_eq!(a.into_intersection(b), Interval::closed(3,5));
    }
    ```
    */
Converts two intervals into their intersection.
Converts two intervals into their intersection .
pub fn into_intersection(self, other: Self) -> Self {
        if self.is_empty() {
            return self;
        }
        if other.is_empty(){
            return other;
        }
        if ! self.intersects(&other) {
            return Self::empty();
        }
        let (l1, u1) =  self.into_bounds().unwrap();
        let (l2, u2) = other.into_bounds().unwrap();
        Self::from_bounds(l1.max(l2), u1.min(u2))
    }
pub fn into_intersection ( self , other : Self ) -> Self { if self . is_empty ( ) { return self ; } if other . is_empty ( ) { return other ; } if ! self . intersects ( & other ) { return Self :: empty ( ) ; } let ( l1 , u1 ) = self . into_bounds ( ) . unwrap ( ) ; let ( l2 , u2 ) = other . into_bounds ( ) . unwrap ( ) ; Self :: from_bounds ( l1 . max ( l2 ) , u1 . min ( u2 ) ) }
Converts two intervals into their intersection.
Converts two intervals into their intersection .
self
other
Self
example
```
use advanced_collections::interval::Interval;
fn main() {
let a = Interval::closed(2,5);
let b = Interval::closed(3,6);
assert_eq!(a.into_intersection(b), Interval::closed(3,5));
}
```
` ` ` use advanced_collections :: interval :: Interval ; fn main () { let a = Interval :: closed ( 2 5 ) ; let b = Interval :: closed ( 3 6 ) ; assert_eq! ( a . into_intersection ( b ) Interval :: closed ( 3 5 )) ; } ` ` `