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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/// A structure for a custom horizontal line.
#[derive(Debug, Clone, Copy, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct HorizontalLine<T> {
    /// Line character.
    pub main: Option<T>,
    /// Line intersection character.
    pub intersection: Option<T>,
    /// Left intersection character.
    pub left: Option<T>,
    /// Right intersection character.
    pub right: Option<T>,
}

impl<T> HorizontalLine<T> {
    /// Creates a new line.
    pub const fn new(
        main: Option<T>,
        intersection: Option<T>,
        left: Option<T>,
        right: Option<T>,
    ) -> Self {
        Self {
            main,
            intersection,
            left,
            right,
        }
    }

    /// Creates a new line.
    pub const fn full(main: T, intersection: T, left: T, right: T) -> Self {
        Self::new(Some(main), Some(intersection), Some(left), Some(right))
    }

    /// Creates a new line.
    pub const fn filled(val: T) -> Self
    where
        T: Copy,
    {
        Self {
            main: Some(val),
            intersection: Some(val),
            left: Some(val),
            right: Some(val),
        }
    }

    /// Creates a new line.
    pub const fn empty() -> Self {
        Self::new(None, None, None, None)
    }

    /// Verifies if the line has any setting set.
    pub const fn is_empty(&self) -> bool {
        self.main.is_none()
            && self.intersection.is_none()
            && self.left.is_none()
            && self.right.is_none()
    }
}