/**
    Merges an interval with another one.

    # Example

    ```
    use advanced_collections::interval::Interval;
    fn main() {
       let mut a = Interval::closed(2,4);
       let b = Interval::closed(4,6);
       a.merge(b).unwrap();
       assert_eq!(a, Interval::closed(2,6));
    }
    ```
    */
Merges an interval with another one.
Merges an interval with another one .
pub fn merge(&mut self, mut other: Self) -> Result<(), Self>{
        if ! self.can_be_merged(&other) {
            return Err(other)
        }
        let s = match self.imp {
            None => {
                swap(self, &mut other);
                return Ok(());
            },
            Some(ref mut a) => a
        };
        let o =  match other.imp {
            None => return Ok(()),
            Some(ref mut a) => a
        };
        if o.lo <s.lo {
            swap(&mut o.lo, &mut s.lo)
        }
        if o.up > s.up {
            swap(&mut o.up, &mut s.up)
        }
        Ok(())
    }
pub fn merge ( & mut self , mut other : Self ) -> Result < ( ) , Self > { if ! self . can_be_merged ( & other ) { return Err ( other ) } let s = match self . imp { None => { swap ( self , & mut other ) ; return Ok ( ( ) ) ; } , Some ( ref mut a ) => a } ; let o = match other . imp { None => return Ok ( ( ) ) , Some ( ref mut a ) => a } ; if o . lo < s . lo { swap ( & mut o . lo , & mut s . lo ) } if o . up > s . up { swap ( & mut o . up , & mut s . up ) } Ok ( ( ) ) }
Merges an interval with another one.
Merges an interval with another one .
&mut self
other
Self
example
```
use advanced_collections::interval::Interval;
fn main() {
let mut a = Interval::closed(2,4);
let b = Interval::closed(4,6);
a.merge(b).unwrap();
assert_eq!(a, Interval::closed(2,6));
}
```
` ` ` use advanced_collections :: interval :: Interval ; fn main () { let mut a = Interval :: closed ( 2 4 ) ; let b = Interval :: closed ( 4 6 ) ; a . merge ( b ) . unwrap () ; assert_eq! ( a Interval :: closed ( 2 6 )) ; } ` ` `