1/// A structure for a vertical line.
2#[derive(Debug, Clone, Copy, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
3pub struct VerticalLine<T> {
4 /// Line character.
5 pub main: Option<T>,
6 /// Line intersection character.
7 pub intersection: Option<T>,
8 /// Left intersection character.
9 pub top: Option<T>,
10 /// Right intersection character.
11 pub bottom: Option<T>,
12}
13
14impl<T> VerticalLine<T> {
15 /// Creates a new line.
16 pub const fn new(
17 main: Option<T>,
18 intersection: Option<T>,
19 top: Option<T>,
20 bottom: Option<T>,
21 ) -> Self {
22 Self {
23 main,
24 intersection,
25 top,
26 bottom,
27 }
28 }
29
30 /// Creates a new line.
31 pub const fn full(main: T, intersection: T, left: T, right: T) -> Self {
32 Self::new(Some(main), Some(intersection), Some(left), Some(right))
33 }
34
35 /// Creates a new line.
36 pub const fn filled(val: T) -> Self
37 where
38 T: Copy,
39 {
40 Self {
41 main: Some(val),
42 intersection: Some(val),
43 top: Some(val),
44 bottom: Some(val),
45 }
46 }
47
48 /// Creates a new line.
49 pub const fn empty() -> Self {
50 Self::new(None, None, None, None)
51 }
52
53 /// Verifies if the line has any setting set.
54 pub const fn is_empty(&self) -> bool {
55 self.main.is_none()
56 && self.intersection.is_none()
57 && self.top.is_none()
58 && self.bottom.is_none()
59 }
60}
61