|
10 | 10 |
|
11 | 11 | //! Tools for writing output. |
12 | 12 |
|
13 | | -use std::{borrow::Cow, io, str}; |
| 13 | +use std::{borrow::Cow, io, mem, str}; |
14 | 14 |
|
15 | 15 | use console::Style; |
16 | 16 | use derive_more::{Deref, DerefMut, Display, From, Into}; |
@@ -68,11 +68,20 @@ impl Styles { |
68 | 68 |
|
69 | 69 | /// Applies the given [`Coloring`] to these [`Styles`]. |
70 | 70 | pub fn apply_coloring(&mut self, color: Coloring) { |
71 | | - match color { |
72 | | - Coloring::Auto => {} |
73 | | - Coloring::Always => self.is_present = true, |
74 | | - Coloring::Never => self.is_present = false, |
75 | | - } |
| 71 | + let is_present = match color { |
| 72 | + Coloring::Always => true, |
| 73 | + Coloring::Never => false, |
| 74 | + Coloring::Auto => return, |
| 75 | + }; |
| 76 | + |
| 77 | + let this = mem::take(self); |
| 78 | + self.ok = this.ok.force_styling(is_present); |
| 79 | + self.skipped = this.skipped.force_styling(is_present); |
| 80 | + self.err = this.err.force_styling(is_present); |
| 81 | + self.retry = this.retry.force_styling(is_present); |
| 82 | + self.header = this.header.force_styling(is_present); |
| 83 | + self.bold = this.bold.force_styling(is_present); |
| 84 | + self.is_present = is_present; |
76 | 85 | } |
77 | 86 |
|
78 | 87 | /// Returns [`Styles`] with brighter colors. |
|
0 commit comments