@@ -108,13 +108,28 @@ impl<'a> Display for DisplayList<'a> {
108108}
109109
110110impl < ' 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 (
112125 snippet:: Snippet {
113126 title,
114127 footer,
115128 slices,
116- opt,
117129 } : snippet:: Snippet < ' a > ,
130+ color : bool ,
131+ anonymized_line_numbers : bool ,
132+ margin : Option < Margin > ,
118133 ) -> DisplayList < ' a > {
119134 let mut body = vec ! [ ] ;
120135 if let Some ( annotation) = title {
@@ -126,36 +141,21 @@ impl<'a> From<snippet::Snippet<'a>> for DisplayList<'a> {
126141 slice,
127142 idx == 0 ,
128143 !footer. is_empty ( ) ,
129- opt . margin ,
144+ margin,
130145 ) ) ;
131146 }
132147
133148 for annotation in footer {
134149 body. append ( & mut format_annotation ( annotation) ) ;
135150 }
136151
137- let FormatOptions {
138- color,
139- anonymized_line_numbers,
140- margin,
141- } = opt;
142-
143152 Self {
144153 body,
145154 stylesheet : get_term_style ( color) ,
146155 anonymized_line_numbers,
147156 margin,
148157 }
149158 }
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" ;
159159
160160 #[ inline]
161161 fn format_annotation_type (
@@ -527,13 +527,6 @@ impl<'a> DisplayList<'a> {
527527 }
528528}
529529
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-
537530#[ derive( Clone , Copy , Debug ) ]
538531pub struct Margin {
539532 /// The available whitespace in the left that can be consumed when centering.
0 commit comments