Function unwind_context::set_colors_enabled
source · pub fn set_colors_enabled(enabled: bool)
Expand description
Enables or disables ANSI colorization.
Note that this function does not check whether the terminal supports
16-ANSI-color mode or not and doesn’t check NO_COLOR
or FORCE_COLOR
environment variables. If you need to enable colorization only if supported
by the terminal, and you don’t need any custom colorization enable
conditions, please use enable_colors_if_supported
.
§Examples
use unwind_context::unwind_context;
fn func(foo: u32, bar: &str) {
let _ctx = unwind_context!(fn(foo, bar));
// ...
}
fn main() {
unwind_context::set_colors_enabled(true);
// ...
func(123, "abc");
// ...
}
#[test]
fn test() {
unwind_context::set_colors_enabled(true);
// ...
func(234, "bcd");
// ...
}