@@ -106,33 +106,12 @@ impl<'a> DisplayList<'a> {
106
106
const WARNING_TXT : & ' static str = "warning" ;
107
107
108
108
pub ( crate ) fn new (
109
- snippet:: Message {
110
- level,
111
- id,
112
- title,
113
- footer,
114
- snippets,
115
- } : snippet:: Message < ' a > ,
109
+ message : snippet:: Message < ' a > ,
116
110
stylesheet : & ' a Stylesheet ,
117
111
anonymized_line_numbers : bool ,
118
112
margin : Option < Margin > ,
119
113
) -> DisplayList < ' a > {
120
- let mut body = vec ! [ ] ;
121
-
122
- body. push ( format_title ( level, id, title) ) ;
123
-
124
- for ( idx, snippet) in snippets. into_iter ( ) . enumerate ( ) {
125
- body. append ( & mut format_snippet (
126
- snippet,
127
- idx == 0 ,
128
- !footer. is_empty ( ) ,
129
- margin,
130
- ) ) ;
131
- }
132
-
133
- for annotation in footer {
134
- body. append ( & mut format_footer ( annotation) ) ;
135
- }
114
+ let body = format_message ( message, margin) ;
136
115
137
116
Self {
138
117
body,
@@ -719,6 +698,36 @@ impl<'a> Iterator for CursorLines<'a> {
719
698
}
720
699
}
721
700
701
+ fn format_message < ' a > (
702
+ snippet:: Message {
703
+ level,
704
+ id,
705
+ title,
706
+ footer,
707
+ snippets,
708
+ } : snippet:: Message < ' a > ,
709
+ margin : Option < Margin > ,
710
+ ) -> Vec < DisplayLine < ' a > > {
711
+ let mut body = vec ! [ ] ;
712
+
713
+ body. push ( format_title ( level, id, title) ) ;
714
+
715
+ for ( idx, snippet) in snippets. into_iter ( ) . enumerate ( ) {
716
+ body. append ( & mut format_snippet (
717
+ snippet,
718
+ idx == 0 ,
719
+ !footer. is_empty ( ) ,
720
+ margin,
721
+ ) ) ;
722
+ }
723
+
724
+ for annotation in footer {
725
+ body. append ( & mut format_footer ( annotation) ) ;
726
+ }
727
+
728
+ body
729
+ }
730
+
722
731
fn format_title < ' a > ( level : crate :: Level , id : Option < & ' a str > , label : & ' a str ) -> DisplayLine < ' a > {
723
732
DisplayLine :: Raw ( DisplayRawLine :: Annotation {
724
733
annotation : Annotation {
0 commit comments