1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3pub struct Size {
4 width: u16,
5 height: u16,
6}
7
8impl Size {
9 pub const fn new(width: u16, height: u16) -> Self {
10 Self {
11 width: if width == 0 { 1 } else { width },
12 height: if height == 0 { 1 } else { height },
13 }
14 }
15
16 pub const fn width(self) -> u16 {
17 self.width
18 }
19
20 pub const fn height(self) -> u16 {
21 self.height
22 }
23
24 pub const fn area(self) -> usize {
25 self.width as usize * self.height as usize
26 }
27}