rspack_error/
colors.rs

1use std::fmt::Display;
2
3use owo_colors::{OwoColorize, Stream::Stdout};
4
5/// Dim the text if the stream supports color.
6#[inline]
7pub fn dim<T>(text: &T) -> impl Display + '_
8where
9  T: Display + OwoColorize,
10{
11  text.if_supports_color(Stdout, |t| t.dimmed())
12}
13
14/// Color the text red if the stream supports color.
15#[inline]
16pub fn red<T>(text: &T) -> impl Display + '_
17where
18  T: Display + OwoColorize,
19{
20  text.if_supports_color(Stdout, |t| t.red())
21}
22
23/// Color the text yellow if the stream supports color.
24#[inline]
25pub fn yellow<T>(text: &T) -> impl Display + '_
26where
27  T: Display + OwoColorize,
28{
29  text.if_supports_color(Stdout, |t| t.yellow())
30}
31
32/// Color the text cyan if the stream supports color.
33#[inline]
34pub fn cyan<T>(text: &T) -> impl Display + '_
35where
36  T: Display + OwoColorize,
37{
38  text.if_supports_color(Stdout, |t| t.cyan())
39}