1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
pub mod region;

use {
    smallvec::SmallVec,
    std::fmt::{Debug, Formatter},
};

#[derive(Copy, Clone, Eq, PartialEq, Default)]
pub struct RectRaw {
    pub x1: i32,
    pub y1: i32,
    pub x2: i32,
    pub y2: i32,
}

impl Debug for RectRaw {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("Rect")
            .field("x1", &self.x1)
            .field("y1", &self.y1)
            .field("x2", &self.x2)
            .field("y2", &self.y2)
            .field("width", &(self.x2 - self.x1))
            .field("height", &(self.y2 - self.y1))
            .finish()
    }
}

impl RectRaw {
    fn is_empty(&self) -> bool {
        self.x1 == self.x2 || self.y1 == self.y2
    }
}

type Container = SmallVec<[RectRaw; 1]>;