ul_next/
rect.rs

1//! A container for Rectangle structure.
2#[derive(Clone, Copy, Debug)]
3/// Rectangle structure
4pub struct Rect<T> {
5    pub left: T,
6    pub top: T,
7    pub right: T,
8    pub bottom: T,
9}
10
11impl Rect<i32> {
12    /// Whether the rectangle is empty or not.
13    pub fn is_empty(&self) -> bool {
14        self.left == 0 && self.top == 0 && self.right == 0 && self.bottom == 0
15    }
16}
17
18impl From<ul_sys::ULRect> for Rect<f32> {
19    fn from(r: ul_sys::ULRect) -> Self {
20        Rect {
21            left: r.left,
22            top: r.top,
23            right: r.right,
24            bottom: r.bottom,
25        }
26    }
27}
28
29impl From<ul_sys::ULIntRect> for Rect<i32> {
30    fn from(r: ul_sys::ULIntRect) -> Self {
31        Rect {
32            left: r.left,
33            top: r.top,
34            right: r.right,
35            bottom: r.bottom,
36        }
37    }
38}
39
40impl From<Rect<f32>> for ul_sys::ULRect {
41    fn from(r: Rect<f32>) -> Self {
42        ul_sys::ULRect {
43            left: r.left,
44            top: r.top,
45            right: r.right,
46            bottom: r.bottom,
47        }
48    }
49}
50
51impl From<Rect<i32>> for ul_sys::ULIntRect {
52    fn from(r: Rect<i32>) -> Self {
53        ul_sys::ULIntRect {
54            left: r.left,
55            top: r.top,
56            right: r.right,
57            bottom: r.bottom,
58        }
59    }
60}