1pub const VERTICAL: &str = "│";
2pub const DOUBLE_VERTICAL: &str = "║";
3pub const THICK_VERTICAL: &str = "┃";
4pub const LIGHT_DOUBLE_DASH_VERTICAL: &str = "╎";
5pub const HEAVY_DOUBLE_DASH_VERTICAL: &str = "╏";
6pub const LIGHT_TRIPLE_DASH_VERTICAL: &str = "┆";
7pub const HEAVY_TRIPLE_DASH_VERTICAL: &str = "┇";
8pub const LIGHT_QUADRUPLE_DASH_VERTICAL: &str = "┊";
9pub const HEAVY_QUADRUPLE_DASH_VERTICAL: &str = "┋";
10
11pub const HORIZONTAL: &str = "─";
12pub const DOUBLE_HORIZONTAL: &str = "═";
13pub const THICK_HORIZONTAL: &str = "━";
14pub const LIGHT_DOUBLE_DASH_HORIZONTAL: &str = "╌";
15pub const HEAVY_DOUBLE_DASH_HORIZONTAL: &str = "╍";
16pub const LIGHT_TRIPLE_DASH_HORIZONTAL: &str = "┄";
17pub const HEAVY_TRIPLE_DASH_HORIZONTAL: &str = "┅";
18pub const LIGHT_QUADRUPLE_DASH_HORIZONTAL: &str = "┈";
19pub const HEAVY_QUADRUPLE_DASH_HORIZONTAL: &str = "┉";
20
21pub const TOP_RIGHT: &str = "┐";
22pub const ROUNDED_TOP_RIGHT: &str = "╮";
23pub const DOUBLE_TOP_RIGHT: &str = "╗";
24pub const THICK_TOP_RIGHT: &str = "┓";
25
26pub const TOP_LEFT: &str = "┌";
27pub const ROUNDED_TOP_LEFT: &str = "╭";
28pub const DOUBLE_TOP_LEFT: &str = "╔";
29pub const THICK_TOP_LEFT: &str = "┏";
30
31pub const BOTTOM_RIGHT: &str = "┘";
32pub const ROUNDED_BOTTOM_RIGHT: &str = "╯";
33pub const DOUBLE_BOTTOM_RIGHT: &str = "╝";
34pub const THICK_BOTTOM_RIGHT: &str = "┛";
35
36pub const BOTTOM_LEFT: &str = "└";
37pub const ROUNDED_BOTTOM_LEFT: &str = "╰";
38pub const DOUBLE_BOTTOM_LEFT: &str = "╚";
39pub const THICK_BOTTOM_LEFT: &str = "┗";
40
41pub const VERTICAL_LEFT: &str = "┤";
42pub const DOUBLE_VERTICAL_LEFT: &str = "╣";
43pub const THICK_VERTICAL_LEFT: &str = "┫";
44
45pub const VERTICAL_RIGHT: &str = "├";
46pub const DOUBLE_VERTICAL_RIGHT: &str = "╠";
47pub const THICK_VERTICAL_RIGHT: &str = "┣";
48
49pub const HORIZONTAL_DOWN: &str = "┬";
50pub const DOUBLE_HORIZONTAL_DOWN: &str = "╦";
51pub const THICK_HORIZONTAL_DOWN: &str = "┳";
52
53pub const HORIZONTAL_UP: &str = "┴";
54pub const DOUBLE_HORIZONTAL_UP: &str = "╩";
55pub const THICK_HORIZONTAL_UP: &str = "┻";
56
57pub const CROSS: &str = "┼";
58pub const DOUBLE_CROSS: &str = "╬";
59pub const THICK_CROSS: &str = "╋";
60
61#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
62pub struct Set<'a> {
63 pub vertical: &'a str,
64 pub horizontal: &'a str,
65 pub top_right: &'a str,
66 pub top_left: &'a str,
67 pub bottom_right: &'a str,
68 pub bottom_left: &'a str,
69 pub vertical_left: &'a str,
70 pub vertical_right: &'a str,
71 pub horizontal_down: &'a str,
72 pub horizontal_up: &'a str,
73 pub cross: &'a str,
74}
75
76impl Default for Set<'_> {
77 fn default() -> Self {
78 NORMAL
79 }
80}
81
82pub const NORMAL: Set = Set {
83 vertical: VERTICAL,
84 horizontal: HORIZONTAL,
85 top_right: TOP_RIGHT,
86 top_left: TOP_LEFT,
87 bottom_right: BOTTOM_RIGHT,
88 bottom_left: BOTTOM_LEFT,
89 vertical_left: VERTICAL_LEFT,
90 vertical_right: VERTICAL_RIGHT,
91 horizontal_down: HORIZONTAL_DOWN,
92 horizontal_up: HORIZONTAL_UP,
93 cross: CROSS,
94};
95
96pub const ROUNDED: Set = Set {
97 top_right: ROUNDED_TOP_RIGHT,
98 top_left: ROUNDED_TOP_LEFT,
99 bottom_right: ROUNDED_BOTTOM_RIGHT,
100 bottom_left: ROUNDED_BOTTOM_LEFT,
101 ..NORMAL
102};
103
104pub const DOUBLE: Set = Set {
105 vertical: DOUBLE_VERTICAL,
106 horizontal: DOUBLE_HORIZONTAL,
107 top_right: DOUBLE_TOP_RIGHT,
108 top_left: DOUBLE_TOP_LEFT,
109 bottom_right: DOUBLE_BOTTOM_RIGHT,
110 bottom_left: DOUBLE_BOTTOM_LEFT,
111 vertical_left: DOUBLE_VERTICAL_LEFT,
112 vertical_right: DOUBLE_VERTICAL_RIGHT,
113 horizontal_down: DOUBLE_HORIZONTAL_DOWN,
114 horizontal_up: DOUBLE_HORIZONTAL_UP,
115 cross: DOUBLE_CROSS,
116};
117
118pub const THICK: Set = Set {
119 vertical: THICK_VERTICAL,
120 horizontal: THICK_HORIZONTAL,
121 top_right: THICK_TOP_RIGHT,
122 top_left: THICK_TOP_LEFT,
123 bottom_right: THICK_BOTTOM_RIGHT,
124 bottom_left: THICK_BOTTOM_LEFT,
125 vertical_left: THICK_VERTICAL_LEFT,
126 vertical_right: THICK_VERTICAL_RIGHT,
127 horizontal_down: THICK_HORIZONTAL_DOWN,
128 horizontal_up: THICK_HORIZONTAL_UP,
129 cross: THICK_CROSS,
130};
131
132pub const LIGHT_DOUBLE_DASHED: Set = Set {
133 vertical: LIGHT_DOUBLE_DASH_VERTICAL,
134 horizontal: LIGHT_DOUBLE_DASH_HORIZONTAL,
135 ..NORMAL
136};
137
138pub const HEAVY_DOUBLE_DASHED: Set = Set {
139 vertical: HEAVY_DOUBLE_DASH_VERTICAL,
140 horizontal: HEAVY_DOUBLE_DASH_HORIZONTAL,
141 ..THICK
142};
143
144pub const LIGHT_TRIPLE_DASHED: Set = Set {
145 vertical: LIGHT_TRIPLE_DASH_VERTICAL,
146 horizontal: LIGHT_TRIPLE_DASH_HORIZONTAL,
147 ..NORMAL
148};
149
150pub const HEAVY_TRIPLE_DASHED: Set = Set {
151 vertical: HEAVY_TRIPLE_DASH_VERTICAL,
152 horizontal: HEAVY_TRIPLE_DASH_HORIZONTAL,
153 ..THICK
154};
155
156pub const LIGHT_QUADRUPLE_DASHED: Set = Set {
157 vertical: LIGHT_QUADRUPLE_DASH_VERTICAL,
158 horizontal: LIGHT_QUADRUPLE_DASH_HORIZONTAL,
159 ..NORMAL
160};
161
162pub const HEAVY_QUADRUPLE_DASHED: Set = Set {
163 vertical: HEAVY_QUADRUPLE_DASH_VERTICAL,
164 horizontal: HEAVY_QUADRUPLE_DASH_HORIZONTAL,
165 ..THICK
166};
167
168#[cfg(test)]
169mod tests {
170 use alloc::format;
171 use alloc::string::String;
172
173 use indoc::{formatdoc, indoc};
174
175 use super::*;
176
177 #[test]
178 fn default() {
179 assert_eq!(Set::default(), NORMAL);
180 }
181
182 fn render(set: Set) -> String {
184 formatdoc!(
185 "{}{}{}{}
186 {}{}{}{}
187 {}{}{}{}
188 {}{}{}{}",
189 set.top_left,
190 set.horizontal,
191 set.horizontal_down,
192 set.top_right,
193 set.vertical,
194 " ",
195 set.vertical,
196 set.vertical,
197 set.vertical_right,
198 set.horizontal,
199 set.cross,
200 set.vertical_left,
201 set.bottom_left,
202 set.horizontal,
203 set.horizontal_up,
204 set.bottom_right
205 )
206 }
207
208 #[test]
209 fn normal() {
210 assert_eq!(
211 render(NORMAL),
212 indoc!(
213 "┌─┬┐
214 │ ││
215 ├─┼┤
216 └─┴┘"
217 )
218 );
219 }
220
221 #[test]
222 fn rounded() {
223 assert_eq!(
224 render(ROUNDED),
225 indoc!(
226 "╭─┬╮
227 │ ││
228 ├─┼┤
229 ╰─┴╯"
230 )
231 );
232 }
233
234 #[test]
235 fn double() {
236 assert_eq!(
237 render(DOUBLE),
238 indoc!(
239 "╔═╦╗
240 ║ ║║
241 ╠═╬╣
242 ╚═╩╝"
243 )
244 );
245 }
246
247 #[test]
248 fn thick() {
249 assert_eq!(
250 render(THICK),
251 indoc!(
252 "┏━┳┓
253 ┃ ┃┃
254 ┣━╋┫
255 ┗━┻┛"
256 )
257 );
258 }
259}