File tree Expand file tree Collapse file tree 2 files changed +27
-21
lines changed Expand file tree Collapse file tree 2 files changed +27
-21
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,29 @@ impl<T: Write> Write for OutputLocation<T> {
41
41
}
42
42
}
43
43
44
+ impl < T : Write > OutputLocation < T > {
45
+ pub fn write_pretty ( & mut self , word : & str , color : term:: color:: Color ) -> io:: Result < ( ) > {
46
+ match self {
47
+ OutputLocation :: Pretty ( ref mut term) => {
48
+ term. fg ( color) ?;
49
+ term. write_all ( word. as_bytes ( ) ) ?;
50
+ term. reset ( ) ?;
51
+ }
52
+ OutputLocation :: Raw ( ref mut stdout) => {
53
+ stdout. write_all ( word. as_bytes ( ) ) ?;
54
+ }
55
+ }
56
+
57
+ self . flush ( )
58
+ }
59
+
60
+ pub fn write_plain < S : AsRef < str > > ( & mut self , s : S ) -> io:: Result < ( ) > {
61
+ let s = s. as_ref ( ) ;
62
+ self . write_all ( s. as_bytes ( ) ) ?;
63
+ self . flush ( )
64
+ }
65
+ }
66
+
44
67
pub struct ConsoleTestDiscoveryState {
45
68
pub log_out : Option < File > ,
46
69
pub tests : usize ,
Original file line number Diff line number Diff line change @@ -69,29 +69,12 @@ impl<T: Write> PrettyFormatter<T> {
69
69
self . write_pretty ( result, color)
70
70
}
71
71
72
- pub fn write_pretty ( & mut self , word : & str , color : term:: color:: Color ) -> io:: Result < ( ) > {
73
- match self . out {
74
- OutputLocation :: Pretty ( ref mut term) => {
75
- if self . use_color {
76
- term. fg ( color) ?;
77
- }
78
- term. write_all ( word. as_bytes ( ) ) ?;
79
- if self . use_color {
80
- term. reset ( ) ?;
81
- }
82
- term. flush ( )
83
- }
84
- OutputLocation :: Raw ( ref mut stdout) => {
85
- stdout. write_all ( word. as_bytes ( ) ) ?;
86
- stdout. flush ( )
87
- }
88
- }
72
+ fn write_pretty ( & mut self , word : & str , color : term:: color:: Color ) -> io:: Result < ( ) > {
73
+ if self . use_color { self . out . write_pretty ( word, color) } else { self . out . write_plain ( word) }
89
74
}
90
75
91
- pub fn write_plain < S : AsRef < str > > ( & mut self , s : S ) -> io:: Result < ( ) > {
92
- let s = s. as_ref ( ) ;
93
- self . out . write_all ( s. as_bytes ( ) ) ?;
94
- self . out . flush ( )
76
+ fn write_plain < S : AsRef < str > > ( & mut self , s : S ) -> io:: Result < ( ) > {
77
+ self . out . write_plain ( s)
95
78
}
96
79
97
80
fn write_time (
You can’t perform that action at this time.
0 commit comments