pub fn into_merged(self, other: Self) -> Result<Self, (Self, Self)>{
        if ! self.can_be_merged(&other){
            return Err((self, other));
        }
        if other.is_empty(){
            return Ok(self);
        }
        if self.is_empty(){
            return Ok(other);
        }

        let (l1, u1) = self.into_bounds().unwrap();
        let (l2, u2) = other.into_bounds().unwrap();

        Ok(Self::from_bounds(l1.min(l2), u1.max(u2)))
    }
/**
    Merges two intervals into one.

    If the merge is unsuccessful, two original intervals are returned.

    # Example

    ```
    use advanced_collections::interval::Interval;
    fn main() {
       let a = Interval::closed(2,4);
       let b = Interval::closed(4,6);
       assert_eq!(a.into_merged(b), Ok(Interval::closed(2,6)));
    }
    ```
    */
Merges two intervals into one.
If the merge is unsuccessful, two original intervals are returned.
Merges two intervals into one . If the merge is unsuccessful two original intervals are returned .
pub fn into_merged(self, other: Self) -> Result<Self, (Self, Self)>{
        if ! self.can_be_merged(&other){
            return Err((self, other));
        }
        if other.is_empty(){
            return Ok(self);
        }
        if self.is_empty(){
            return Ok(other);
        }
        let (l1, u1) = self.into_bounds().unwrap();
        let (l2, u2) = other.into_bounds().unwrap();
        Ok(Self::from_bounds(l1.min(l2), u1.max(u2)))
    }
pub fn into_merged ( self , other : Self ) -> Result < Self , ( Self , Self ) > { if ! self . can_be_merged ( & other ) { return Err ( ( self , other ) ) ; } if other . is_empty ( ) { return Ok ( self ) ; } if self . is_empty ( ) { return Ok ( other ) ; } let ( l1 , u1 ) = self . into_bounds ( ) . unwrap ( ) ; let ( l2 , u2 ) = other . into_bounds ( ) . unwrap ( ) ; Ok ( Self :: from_bounds ( l1 . min ( l2 ) , u1 . max ( u2 ) ) ) }
Merges two intervals into one.
Merges two intervals into one .
self
other
Self
self
other
Self
example
```
use advanced_collections::interval::Interval;
fn main() {
let a = Interval::closed(2,4);
let b = Interval::closed(4,6);
assert_eq!(a.into_merged(b), Ok(Interval::closed(2,6)));
}
```
` ` ` use advanced_collections :: interval :: Interval ; fn main () { let a = Interval :: closed ( 2 4 ) ; let b = Interval :: closed ( 4 6 ) ; assert_eq! ( a . into_merged ( b ) Ok ( Interval :: closed ( 2 6 ))) ; } ` ` `