#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Borders<T> {
pub top: Option<T>,
pub top_left: Option<T>,
pub top_right: Option<T>,
pub top_intersection: Option<T>,
pub bottom: Option<T>,
pub bottom_left: Option<T>,
pub bottom_right: Option<T>,
pub bottom_intersection: Option<T>,
pub horizontal: Option<T>,
pub vertical: Option<T>,
pub intersection: Option<T>,
pub left: Option<T>,
pub left_intersection: Option<T>,
pub right: Option<T>,
pub right_intersection: Option<T>,
}
impl<T> Borders<T> {
pub const fn empty() -> Self {
Self {
top: None,
top_left: None,
top_right: None,
top_intersection: None,
bottom: None,
bottom_left: None,
bottom_right: None,
bottom_intersection: None,
horizontal: None,
left: None,
right: None,
vertical: None,
left_intersection: None,
right_intersection: None,
intersection: None,
}
}
pub const fn filled(val: T) -> Self
where
T: Copy,
{
Self {
top: Some(val),
top_left: Some(val),
top_right: Some(val),
top_intersection: Some(val),
bottom: Some(val),
bottom_left: Some(val),
bottom_right: Some(val),
bottom_intersection: Some(val),
horizontal: Some(val),
left: Some(val),
right: Some(val),
vertical: Some(val),
left_intersection: Some(val),
right_intersection: Some(val),
intersection: Some(val),
}
}
pub const fn is_empty(&self) -> bool {
self.top.is_none()
&& self.top_left.is_none()
&& self.top_right.is_none()
&& self.top_intersection.is_none()
&& self.bottom.is_none()
&& self.bottom_left.is_none()
&& self.bottom_right.is_none()
&& self.bottom_intersection.is_none()
&& self.horizontal.is_none()
&& self.left.is_none()
&& self.right.is_none()
&& self.vertical.is_none()
&& self.left_intersection.is_none()
&& self.right_intersection.is_none()
&& self.intersection.is_none()
}
pub const fn has_left(&self) -> bool {
self.left.is_some()
|| self.left_intersection.is_some()
|| self.top_left.is_some()
|| self.bottom_left.is_some()
}
pub const fn has_right(&self) -> bool {
self.right.is_some()
|| self.right_intersection.is_some()
|| self.top_right.is_some()
|| self.bottom_right.is_some()
}
pub const fn has_top(&self) -> bool {
self.top.is_some()
|| self.top_intersection.is_some()
|| self.top_left.is_some()
|| self.top_right.is_some()
}
pub const fn has_bottom(&self) -> bool {
self.bottom.is_some()
|| self.bottom_intersection.is_some()
|| self.bottom_left.is_some()
|| self.bottom_right.is_some()
}
pub const fn has_horizontal(&self) -> bool {
self.horizontal.is_some()
|| self.left_intersection.is_some()
|| self.right_intersection.is_some()
|| self.intersection.is_some()
}
pub const fn has_vertical(&self) -> bool {
self.intersection.is_some()
|| self.vertical.is_some()
|| self.top_intersection.is_some()
|| self.bottom_intersection.is_some()
}
pub fn convert_into<T1>(self) -> Borders<T1>
where
T1: From<T>,
{
Borders {
left: self.left.map(Into::into),
right: self.right.map(Into::into),
top: self.top.map(Into::into),
bottom: self.bottom.map(Into::into),
bottom_intersection: self.bottom_intersection.map(Into::into),
bottom_left: self.bottom_left.map(Into::into),
bottom_right: self.bottom_right.map(Into::into),
horizontal: self.horizontal.map(Into::into),
intersection: self.intersection.map(Into::into),
left_intersection: self.left_intersection.map(Into::into),
right_intersection: self.right_intersection.map(Into::into),
top_intersection: self.top_intersection.map(Into::into),
top_left: self.top_left.map(Into::into),
top_right: self.top_right.map(Into::into),
vertical: self.vertical.map(Into::into),
}
}
}