@@ -86,21 +86,19 @@ impl ColorableTerminal {
8686 Err ( e) => e. into_inner ( ) ,
8787 } ;
8888
89- ColorableTerminalLocked {
90- locked : match & * locked {
91- TerminalInner :: Stdout ( s) => TerminalInnerLocked :: Stdout ( AutoStream :: new (
92- s. as_inner ( ) . lock ( ) ,
93- self . color_choice ,
94- ) ) ,
95- TerminalInner :: Stderr ( s) => TerminalInnerLocked :: Stderr ( AutoStream :: new (
96- s. as_inner ( ) . lock ( ) ,
97- self . color_choice ,
98- ) ) ,
99- #[ cfg( feature = "test" ) ]
100- TerminalInner :: TestWriter ( w) => {
101- TerminalInnerLocked :: TestWriter ( StripStream :: new ( Box :: new ( w. clone ( ) ) ) )
102- }
103- } ,
89+ match & * locked {
90+ TerminalInner :: Stdout ( s) => ColorableTerminalLocked :: Stdout ( AutoStream :: new (
91+ s. as_inner ( ) . lock ( ) ,
92+ self . color_choice ,
93+ ) ) ,
94+ TerminalInner :: Stderr ( s) => ColorableTerminalLocked :: Stderr ( AutoStream :: new (
95+ s. as_inner ( ) . lock ( ) ,
96+ self . color_choice ,
97+ ) ) ,
98+ #[ cfg( feature = "test" ) ]
99+ TerminalInner :: TestWriter ( w) => {
100+ ColorableTerminalLocked :: TestWriter ( StripStream :: new ( Box :: new ( w. clone ( ) ) ) )
101+ }
104102 }
105103 }
106104
@@ -218,47 +216,43 @@ impl std::fmt::Debug for ColorableTerminal {
218216 }
219217}
220218
221- pub struct ColorableTerminalLocked {
222- locked : TerminalInnerLocked ,
219+ pub enum ColorableTerminalLocked {
220+ Stdout ( AutoStream < io:: StdoutLock < ' static > > ) ,
221+ Stderr ( AutoStream < io:: StderrLock < ' static > > ) ,
222+ #[ cfg( feature = "test" ) ]
223+ TestWriter ( StripStream < Box < dyn Write > > ) ,
224+ }
225+
226+ impl ColorableTerminalLocked {
227+ fn as_write ( & mut self ) -> & mut dyn io:: Write {
228+ match self {
229+ Self :: Stdout ( s) => s,
230+ Self :: Stderr ( s) => s,
231+ #[ cfg( feature = "test" ) ]
232+ Self :: TestWriter ( w) => w,
233+ }
234+ }
223235}
224236
225237impl io:: Write for ColorableTerminalLocked {
226238 fn write ( & mut self , buf : & [ u8 ] ) -> io:: Result < usize > {
227- self . locked . as_write ( ) . write ( buf)
239+ self . as_write ( ) . write ( buf)
228240 }
229241
230242 fn write_vectored ( & mut self , bufs : & [ std:: io:: IoSlice < ' _ > ] ) -> std:: io:: Result < usize > {
231- self . locked . as_write ( ) . write_vectored ( bufs)
243+ self . as_write ( ) . write_vectored ( bufs)
232244 }
233245
234246 fn flush ( & mut self ) -> io:: Result < ( ) > {
235- self . locked . as_write ( ) . flush ( )
247+ self . as_write ( ) . flush ( )
236248 }
237249
238250 fn write_all ( & mut self , buf : & [ u8 ] ) -> std:: io:: Result < ( ) > {
239- self . locked . as_write ( ) . write_all ( buf)
251+ self . as_write ( ) . write_all ( buf)
240252 }
241253
242254 fn write_fmt ( & mut self , args : std:: fmt:: Arguments < ' _ > ) -> std:: io:: Result < ( ) > {
243- self . locked . as_write ( ) . write_fmt ( args)
244- }
245- }
246-
247- enum TerminalInnerLocked {
248- Stdout ( AutoStream < io:: StdoutLock < ' static > > ) ,
249- Stderr ( AutoStream < io:: StderrLock < ' static > > ) ,
250- #[ cfg( feature = "test" ) ]
251- TestWriter ( StripStream < Box < dyn Write > > ) ,
252- }
253-
254- impl TerminalInnerLocked {
255- fn as_write ( & mut self ) -> & mut dyn io:: Write {
256- match self {
257- TerminalInnerLocked :: Stdout ( s) => s,
258- TerminalInnerLocked :: Stderr ( s) => s,
259- #[ cfg( feature = "test" ) ]
260- TerminalInnerLocked :: TestWriter ( w) => w,
261- }
255+ self . as_write ( ) . write_fmt ( args)
262256 }
263257}
264258
0 commit comments