@@ -58,7 +58,7 @@ struct Stats {
5858}
5959
6060impl Stats {
61- fn new ( ) -> Self {
61+ const fn new ( ) -> Self {
6262 Self {
6363 total : 0 ,
6464 passed : 0 ,
@@ -99,7 +99,7 @@ impl Stats {
9999 )
100100 }
101101
102- fn status_text ( & self ) -> & ' static str {
102+ const fn status_text ( & self ) -> & ' static str {
103103 if self . failed > 0 {
104104 "FAIL"
105105 } else if self . total == 0 {
@@ -110,7 +110,7 @@ impl Stats {
110110 }
111111}
112112
113- fn scenario_status ( el : & Element ) -> & str {
113+ fn scenario_status ( el : & Element ) -> & ' static str {
114114 for s in & el. steps {
115115 if s. result . status == "failed" {
116116 return "failed" ;
@@ -159,7 +159,7 @@ pub fn generate(json_path: &Path, html_path: &Path) -> std::io::Result<()> {
159159 . map ( |d| {
160160 let secs = d. as_secs ( ) ;
161161 let days = secs / 86400 ;
162- let y = 1970 + ( days * 400 / 146097 ) ;
162+ let y = 1970 + ( days * 400 / 146_097 ) ;
163163 format ! ( "{y}-xx-xx (epoch {secs})" )
164164 } )
165165 . unwrap_or_default ( ) ;
@@ -317,46 +317,46 @@ pub fn generate(json_path: &Path, html_path: &Path) -> std::io::Result<()> {
317317 "<details class=\" scenario\" >\n <summary class=\" scenario-row\" >\n "
318318 )
319319 . unwrap ( ) ;
320- write ! (
320+ writeln ! (
321321 html,
322- " <span class=\" badge {badge_class}\" >{badge_text}</span>\n "
322+ " <span class=\" badge {badge_class}\" >{badge_text}</span>"
323323 )
324324 . unwrap ( ) ;
325- write ! (
325+ writeln ! (
326326 html,
327- " <span class=\" scenario-name\" >{}</span>\n " ,
327+ " <span class=\" scenario-name\" >{}</span>" ,
328328 escape( & scenario. name)
329329 )
330330 . unwrap ( ) ;
331331 for tag in & scenario. tags {
332- write ! ( html, " <span class=\" tag\" >{}</span>\n " , escape( & tag. name) ) . unwrap ( ) ;
332+ writeln ! ( html, " <span class=\" tag\" >{}</span>" , escape( & tag. name) ) . unwrap ( ) ;
333333 }
334- write ! ( html, " <span class=\" elapsed\" >{dur_ms}ms</span>\n " ) . unwrap ( ) ;
335- write ! ( html, "</summary>\n " ) . unwrap ( ) ;
334+ writeln ! ( html, " <span class=\" elapsed\" >{dur_ms}ms</span>" ) . unwrap ( ) ;
335+ writeln ! ( html, "</summary>" ) . unwrap ( ) ;
336336
337- write ! ( html, "<div class=\" steps\" >\n " ) . unwrap ( ) ;
337+ writeln ! ( html, "<div class=\" steps\" >" ) . unwrap ( ) ;
338338 for step in & scenario. steps {
339339 let ( icon, icon_class) = match step. result . status . as_str ( ) {
340340 "passed" => ( "✔" , "pass" ) ,
341341 "failed" => ( "✘" , "fail" ) ,
342342 _ => ( "○" , "" ) ,
343343 } ;
344344 let step_ms = step. result . duration / 1_000_000 ;
345- write ! (
345+ writeln ! (
346346 html,
347- " <div class=\" step\" ><span class=\" step-icon {icon_class}\" >{icon}</span><span class=\" step-keyword\" >{}</span>{}<span class=\" step-duration\" >{step_ms}ms</span></div>\n " ,
347+ " <div class=\" step\" ><span class=\" step-icon {icon_class}\" >{icon}</span><span class=\" step-keyword\" >{}</span>{}<span class=\" step-duration\" >{step_ms}ms</span></div>" ,
348348 escape( & step. keyword) ,
349349 escape( & step. name) ,
350350 ) . unwrap ( ) ;
351351
352352 if let Some ( err) = & step. result . error_message {
353- write ! ( html, " <div class=\" error-box\" >{}</div>\n " , escape( err) ) . unwrap ( ) ;
353+ writeln ! ( html, " <div class=\" error-box\" >{}</div>" , escape( err) ) . unwrap ( ) ;
354354 }
355355 }
356356 write ! ( html, "</div>\n </details>\n " ) . unwrap ( ) ;
357357 }
358358
359- write ! ( html, "</div>\n " ) . unwrap ( ) ;
359+ writeln ! ( html, "</div>" ) . unwrap ( ) ;
360360 }
361361
362362 write ! ( html, "</div>\n </body>\n </html>\n " ) . unwrap ( ) ;
@@ -373,10 +373,10 @@ fn write_stats_table(html: &mut String, title: &str, rows: &[(String, &Stats)])
373373 )
374374 . unwrap ( ) ;
375375 for ( label, stats) in rows {
376- write ! (
376+ writeln ! (
377377 html,
378378 "<tr><td><a href=\" #\" >{}</a></td><td class=\" num\" >{}</td><td class=\" num\" >{}</td>\
379- <td class=\" num\" >{}</td><td class=\" num\" >{}</td><td class=\" num\" >{}</td><td>{}</td></tr>\n ",
379+ <td class=\" num\" >{}</td><td class=\" num\" >{}</td><td class=\" num\" >{}</td><td>{}</td></tr>",
380380 escape( label) ,
381381 stats. total,
382382 stats. passed,
@@ -386,7 +386,7 @@ fn write_stats_table(html: &mut String, title: &str, rows: &[(String, &Stats)])
386386 stats. bar_html( ) ,
387387 ) . unwrap ( ) ;
388388 }
389- write ! ( html, "</table>\n " ) . unwrap ( ) ;
389+ writeln ! ( html, "</table>" ) . unwrap ( ) ;
390390}
391391
392392fn escape ( s : & str ) -> String {
0 commit comments