@@ -108,13 +108,28 @@ impl<'a> Display for DisplayList<'a> {
108
108
}
109
109
110
110
impl < ' a > From < snippet:: Snippet < ' a > > for DisplayList < ' a > {
111
- fn from (
111
+ fn from ( snippet : snippet:: Snippet < ' a > ) -> DisplayList < ' a > {
112
+ Self :: new ( snippet, false , false , None )
113
+ }
114
+ }
115
+
116
+ impl < ' a > DisplayList < ' a > {
117
+ const ANONYMIZED_LINE_NUM : & ' static str = "LL" ;
118
+ const ERROR_TXT : & ' static str = "error" ;
119
+ const HELP_TXT : & ' static str = "help" ;
120
+ const INFO_TXT : & ' static str = "info" ;
121
+ const NOTE_TXT : & ' static str = "note" ;
122
+ const WARNING_TXT : & ' static str = "warning" ;
123
+
124
+ pub ( crate ) fn new (
112
125
snippet:: Snippet {
113
126
title,
114
127
footer,
115
128
slices,
116
- opt,
117
129
} : snippet:: Snippet < ' a > ,
130
+ color : bool ,
131
+ anonymized_line_numbers : bool ,
132
+ margin : Option < Margin > ,
118
133
) -> DisplayList < ' a > {
119
134
let mut body = vec ! [ ] ;
120
135
if let Some ( annotation) = title {
@@ -126,36 +141,21 @@ impl<'a> From<snippet::Snippet<'a>> for DisplayList<'a> {
126
141
slice,
127
142
idx == 0 ,
128
143
!footer. is_empty ( ) ,
129
- opt . margin ,
144
+ margin,
130
145
) ) ;
131
146
}
132
147
133
148
for annotation in footer {
134
149
body. append ( & mut format_annotation ( annotation) ) ;
135
150
}
136
151
137
- let FormatOptions {
138
- color,
139
- anonymized_line_numbers,
140
- margin,
141
- } = opt;
142
-
143
152
Self {
144
153
body,
145
154
stylesheet : get_term_style ( color) ,
146
155
anonymized_line_numbers,
147
156
margin,
148
157
}
149
158
}
150
- }
151
-
152
- impl < ' a > DisplayList < ' a > {
153
- const ANONYMIZED_LINE_NUM : & ' static str = "LL" ;
154
- const ERROR_TXT : & ' static str = "error" ;
155
- const HELP_TXT : & ' static str = "help" ;
156
- const INFO_TXT : & ' static str = "info" ;
157
- const NOTE_TXT : & ' static str = "note" ;
158
- const WARNING_TXT : & ' static str = "warning" ;
159
159
160
160
#[ inline]
161
161
fn format_annotation_type (
@@ -527,13 +527,6 @@ impl<'a> DisplayList<'a> {
527
527
}
528
528
}
529
529
530
- #[ derive( Debug , Default , Copy , Clone ) ]
531
- pub struct FormatOptions {
532
- pub color : bool ,
533
- pub anonymized_line_numbers : bool ,
534
- pub margin : Option < Margin > ,
535
- }
536
-
537
530
#[ derive( Clone , Copy , Debug ) ]
538
531
pub struct Margin {
539
532
/// The available whitespace in the left that can be consumed when centering.
0 commit comments