shape-core 0.1.17

Definition of geometry shapes
Documentation
use std::ops::BitOrAssign;
use super::*;

impl<T> BitOrAssign for Rectangle<T> where T: PartialOrd {
    /// Returns a larger rectangle that encompasses these two rectangles
    fn bitor_assign(&mut self, rhs: Self) {
        if rhs.min.x < self.min.x {
            self.min.x = rhs.min.x;
        }
        if rhs.min.y < self.min.y {
            self.min.y = rhs.min.y;
        }
        if rhs.max.x > self.max.x {
            self.max.x = rhs.max.x;
        }
        if rhs.max.y > self.max.y {
            self.max.y = rhs.max.y;
        }
    }
}

impl<T> BitAndAssign for Rectangle<T> where T: PartialOrd {
    /// Returns the intersection of two rectangles, possibly with negative area, meaning the empty set
    fn bitand_assign(&mut self, rhs: Self) {
        if rhs.min.x > self.min.x {
            self.min.x = rhs.min.x;
        }
        if rhs.min.y > self.min.y {
            self.min.y = rhs.min.y;
        }
        if rhs.max.x < self.max.x {
            self.max.x = rhs.max.x;
        }
        if rhs.max.y < self.max.y {
            self.max.y = rhs.max.y;
        }

    }
}