rustidy_print/
whitespace.rs1use {
5 crate::Print,
6 rustidy_util::{
7 Whitespace,
8 whitespace::{BlockComment, Comment, LineComment, PureWhitespace, WhitespaceInner},
9 },
10};
11
12impl Print for Whitespace {
13 fn print(&self, f: &mut crate::PrintFmt) {
14 self.0.print(f);
15 }
16
17 fn print_non_ws(&self, _f: &mut crate::PrintFmt) {
18 }
20}
21
22impl Print for WhitespaceInner {
23 fn print(&self, f: &mut crate::PrintFmt) {
24 self.first.print(f);
25 for (comment, pure) in &self.rest {
26 comment.print(f);
27 pure.print(f);
28 }
29 }
30
31 fn print_non_ws(&self, _f: &mut crate::PrintFmt) {}
32}
33
34impl Print for Comment {
35 fn print(&self, f: &mut crate::PrintFmt) {
36 match self {
37 Self::Line(comment) => comment.print(f),
38 Self::Block(comment) => comment.print(f),
39 }
40 }
41
42 fn print_non_ws(&self, _f: &mut crate::PrintFmt) {}
43}
44
45impl Print for BlockComment {
46 fn print(&self, f: &mut crate::PrintFmt) {
47 self.0.print(f);
48 }
49
50 fn print_non_ws(&self, _f: &mut crate::PrintFmt) {}
51}
52
53impl Print for LineComment {
54 fn print(&self, f: &mut crate::PrintFmt) {
55 self.0.print(f);
56 }
57
58 fn print_non_ws(&self, _f: &mut crate::PrintFmt) {}
59}
60
61impl Print for PureWhitespace {
62 fn print(&self, f: &mut crate::PrintFmt) {
63 self.0.print(f);
64 }
65
66 fn print_non_ws(&self, _f: &mut crate::PrintFmt) {}
67}