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 36 37 38 39 40 41 42 43 44 45
/// A structure which represents 4 box sides.
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Sides<T> {
/// Top side.
pub top: T,
/// Bottom side.
pub bottom: T,
/// Left side.
pub left: T,
/// Right side.
pub right: T,
}
impl<T> Sides<T> {
/// Creates a new object.
pub const fn new(left: T, right: T, top: T, bottom: T) -> Self {
Self {
top,
bottom,
left,
right,
}
}
/// Creates a new object.
pub const fn filled(value: T) -> Self
where
T: Copy,
{
Self::new(value, value, value, value)
}
/// Creates a new object.
pub fn convert_into<T1>(self) -> Sides<T1>
where
T: Into<T1>,
{
Sides::new(
self.left.into(),
self.right.into(),
self.top.into(),
self.bottom.into(),
)
}
}