pub fn union(&self, other: &Rect) -> Rect {
    match (self.is_empty(), other.is_empty()) {
      (true, true) => Rect::default(),
      (true, false) => *other,
      (false, true) => *self,
      (false, false) => {
        let mut out = Rect::default();

        // horizontal intersection
        let mut ha_min = self.x;
        let mut ha_max = ha_min + self.w;
        let hb_min = other.x;
        let hb_max = hb_min + other.w;
        if hb_min < ha_min {
          ha_min = hb_min;
        }
        out.x = ha_min;
        if hb_max > ha_max {
          ha_max = hb_max;
        }
        out.w = ha_max - ha_min;

        // vertical intersection
        let mut va_min = self.y;
        let mut va_max = va_min + self.h;
        let vb_min = other.y;
        let vb_max = vb_min + other.h;
        if vb_min < va_min {
          va_min = vb_min;
        }
        out.y = va_min;
        if vb_max > va_max {
          va_max = vb_max;
        }
        out.h = va_max - va_min;

        out
      }
    }
  }
/// Gives a `Rect` that's a union between this and the other rect.
///
/// * If self is empty, you just get the other rect.
/// * If the other rect is empty, you just get self.
/// * If _both_ are empty then you get a default rect.
Gives a `Rect` that's a union between this and the other rect.
If self is empty, you just get the other rect.
If the other rect is empty, you just get self.
If _both_ are empty then you get a default rect.
Gives a ` Rect ` that ' s a union between this and the other rect . If self is empty you just get the other rect . If the other rect is empty you just get self . If _both_ are empty then you get a default rect .
pub fn union(&self, other: &Rect) -> Rect {
    match (self.is_empty(), other.is_empty()) {
      (true, true) => Rect::default(),
      (true, false) => *other,
      (false, true) => *self,
      (false, false) => {
        let mut out = Rect::default();
        // horizontal intersection
        let mut ha_min = self.x;
        let mut ha_max = ha_min + self.w;
        let hb_min = other.x;
        let hb_max = hb_min + other.w;
        if hb_min < ha_min {
          ha_min = hb_min;
        }
        out.x = ha_min;
        if hb_max > ha_max {
          ha_max = hb_max;
        }
        out.w = ha_max - ha_min;
        // vertical intersection
        let mut va_min = self.y;
        let mut va_max = va_min + self.h;
        let vb_min = other.y;
        let vb_max = vb_min + other.h;
        if vb_min < va_min {
          va_min = vb_min;
        }
        out.y = va_min;
        if vb_max > va_max {
          va_max = vb_max;
        }
        out.h = va_max - va_min;
        out
      }
    }
  }
pub fn union ( & self , other : & Rect ) -> Rect { match ( self . is_empty ( ) , other . is_empty ( ) ) { ( true , true ) => Rect :: default ( ) , ( true , false ) => * other , ( false , true ) => * self , ( false , false ) => { let mut out = Rect :: default ( ) ; // horizontal intersection let mut ha_min = self . x ; let mut ha_max = ha_min + self . w ; let hb_min = other . x ; let hb_max = hb_min + other . w ; if hb_min < ha_min { ha_min = hb_min ; } out . x = ha_min ; if hb_max > ha_max { ha_max = hb_max ; } out . w = ha_max - ha_min ; // vertical intersection let mut va_min = self . y ; let mut va_max = va_min + self . h ; let vb_min = other . y ; let vb_max = vb_min + other . h ; if vb_min < va_min { va_min = vb_min ; } out . y = va_min ; if vb_max > va_max { va_max = vb_max ; } out . h = va_max - va_min ; out } } }
Gives a `Rect` that's a union between this and the other rect.
Gives a ` Rect ` that ' s a union between this and the other rect .
&self
other
&Rect
&self
other
&Rect