tabled/features/style/
line.rs#[derive(Debug, Default, Clone, Copy)]
pub struct Line {
pub(crate) main: Option<char>,
pub(crate) intersection: Option<char>,
pub(crate) connector1: Option<char>,
pub(crate) connector2: Option<char>,
}
impl Line {
pub const fn new(
main: Option<char>,
intersection: Option<char>,
connector1: Option<char>,
connector2: Option<char>,
) -> Self {
Self {
main,
intersection,
connector1,
connector2,
}
}
pub const fn full(main: char, intersection: char, connector1: char, connector2: char) -> Self {
Self::new(
Some(main),
Some(intersection),
Some(connector1),
Some(connector2),
)
}
pub const fn filled(c: char) -> Self {
Self::full(c, c, c, c)
}
pub const fn empty() -> Self {
Self::new(None, None, None, None)
}
pub const fn is_empty(&self) -> bool {
self.main.is_none()
&& self.intersection.is_none()
&& self.connector1.is_none()
&& self.connector2.is_none()
}
}
impl From<Line> for papergrid::HorizontalLine<char> {
fn from(l: Line) -> Self {
Self {
main: l.main,
intersection: l.intersection,
left: l.connector1,
right: l.connector2,
}
}
}
impl From<Line> for papergrid::VerticalLine<char> {
fn from(l: Line) -> Self {
Self {
main: l.main,
intersection: l.intersection,
top: l.connector1,
bottom: l.connector2,
}
}
}