1/// A line data structure.
2#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord)]
3pub struct Line<T> {
4 /// A horizontal/vertical character.
5 pub main: T,
6 /// A horizontal/vertical intersection.
7 pub intersection: Option<T>,
8 /// A horizontal left / vertical top intersection.
9 pub connect1: Option<T>,
10 /// A horizontal right / vertical bottom intersection.
11 pub connect2: Option<T>,
12}
13
14impl<T> Line<T> {
15 /// Creates a new line.
16 pub const fn new(
17 main: T,
18 intersection: Option<T>,
19 connect1: Option<T>,
20 connect2: Option<T>,
21 ) -> Self {
22 Self {
23 main,
24 intersection,
25 connect1,
26 connect2,
27 }
28 }
29
30 /// Creates a new line.
31 pub const fn filled(val: T) -> Self
32 where
33 T: Copy,
34 {
35 Self {
36 main: val,
37 intersection: Some(val),
38 connect1: Some(val),
39 connect2: Some(val),
40 }
41 }
42}
43