1 | /// A structure which represents 4 box sides. |
2 | #[derive (Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] |
3 | pub struct Sides<T> { |
4 | /// Top side. |
5 | pub top: T, |
6 | /// Bottom side. |
7 | pub bottom: T, |
8 | /// Left side. |
9 | pub left: T, |
10 | /// Right side. |
11 | pub right: T, |
12 | } |
13 | |
14 | impl<T> Sides<T> { |
15 | /// Creates a new object. |
16 | pub const fn new(left: T, right: T, top: T, bottom: T) -> Self { |
17 | Self { |
18 | top, |
19 | bottom, |
20 | left, |
21 | right, |
22 | } |
23 | } |
24 | |
25 | /// Creates a new object. |
26 | pub const fn filled(value: T) -> Self |
27 | where |
28 | T: Copy, |
29 | { |
30 | Self { |
31 | top: value, |
32 | bottom: value, |
33 | left: value, |
34 | right: value, |
35 | } |
36 | } |
37 | } |
38 | |