pub(crate) struct ColorsEnabledGuard {
prior_stdout: bool,
prior_stderr: bool,
}
impl ColorsEnabledGuard {
pub(crate) fn set(enabled: bool) -> Self {
let prior_stdout = console::colors_enabled();
let prior_stderr = console::colors_enabled_stderr();
console::set_colors_enabled(enabled);
console::set_colors_enabled_stderr(enabled);
Self {
prior_stdout,
prior_stderr,
}
}
}
impl Drop for ColorsEnabledGuard {
fn drop(&mut self) {
console::set_colors_enabled(self.prior_stdout);
console::set_colors_enabled_stderr(self.prior_stderr);
}
}