1- use std:: { borrow:: Cow , io, io :: prelude :: Write } ;
1+ use std:: { borrow:: Cow , io} ;
22
33use super :: OutputFormatter ;
44use crate :: {
5- console:: { ConsoleTestDiscoveryState , ConsoleTestState , OutputLocation } ,
5+ console:: { ConsoleTestDiscoveryState , ConsoleTestState , Output } ,
66 test_result:: TestResult ,
77 time,
88 types:: TestDesc ,
99} ;
1010
11- pub ( crate ) struct JsonFormatter < T > {
12- out : OutputLocation < T > ,
11+ pub ( crate ) struct JsonFormatter < ' a > {
12+ out : & ' a mut dyn Output ,
1313}
1414
15- impl < T : Write > JsonFormatter < T > {
16- pub fn new ( out : OutputLocation < T > ) -> Self {
15+ impl < ' a > JsonFormatter < ' a > {
16+ pub fn new ( out : & ' a mut dyn Output ) -> Self {
1717 Self { out }
1818 }
1919
@@ -23,7 +23,7 @@ impl<T: Write> JsonFormatter<T> {
2323 // by issuing `write_all` calls line-by-line.
2424 assert_eq ! ( s. chars( ) . last( ) , Some ( '\n' ) ) ;
2525
26- self . out . write_all ( s . as_ref ( ) )
26+ self . out . write_plain ( s )
2727 }
2828
2929 fn write_event (
@@ -56,7 +56,7 @@ impl<T: Write> JsonFormatter<T> {
5656 }
5757}
5858
59- impl < T : Write > OutputFormatter for JsonFormatter < T > {
59+ impl OutputFormatter for JsonFormatter < ' _ > {
6060 fn write_discovery_start ( & mut self ) -> io:: Result < ( ) > {
6161 self . writeln_message ( concat ! ( r#"{ "type": "suite", "event": "discovery" }"# , "\n " ) )
6262 }
0 commit comments