]>
git.proxmox.com Git - rustc.git/blob - vendor/snapbox/src/report/color.rs
1 #[derive(Copy, Clone, Debug)]
4 pub(crate) info
: styled
::Style
,
5 pub(crate) warn
: styled
::Style
,
6 pub(crate) error
: styled
::Style
,
7 pub(crate) hint
: styled
::Style
,
8 pub(crate) expected
: styled
::Style
,
9 pub(crate) actual
: styled
::Style
,
13 #[cfg(feature = "color")]
14 pub fn always() -> Self {
16 info
: styled
::Style(yansi
::Style
::new(yansi
::Color
::Green
)),
17 warn
: styled
::Style(yansi
::Style
::new(yansi
::Color
::Yellow
)),
18 error
: styled
::Style(yansi
::Style
::new(yansi
::Color
::Red
)),
19 hint
: styled
::Style(yansi
::Style
::new(yansi
::Color
::Unset
).dimmed()),
20 expected
: styled
::Style(yansi
::Style
::new(yansi
::Color
::Green
).underline()),
21 actual
: styled
::Style(yansi
::Style
::new(yansi
::Color
::Red
).underline()),
25 #[cfg(not(feature = "color"))]
26 pub fn always() -> Self {
30 pub fn never() -> Self {
32 info
: Default
::default(),
33 warn
: Default
::default(),
34 error
: Default
::default(),
35 hint
: Default
::default(),
36 expected
: Default
::default(),
37 actual
: Default
::default(),
41 pub fn auto() -> Self {
49 pub fn info
<D
: std
::fmt
::Display
>(self, item
: D
) -> Styled
<D
> {
53 pub fn warn
<D
: std
::fmt
::Display
>(self, item
: D
) -> Styled
<D
> {
57 pub fn error
<D
: std
::fmt
::Display
>(self, item
: D
) -> Styled
<D
> {
58 self.error
.paint(item
)
61 pub fn hint
<D
: std
::fmt
::Display
>(self, item
: D
) -> Styled
<D
> {
65 pub fn expected
<D
: std
::fmt
::Display
>(self, item
: D
) -> Styled
<D
> {
66 self.expected
.paint(item
)
69 pub fn actual
<D
: std
::fmt
::Display
>(self, item
: D
) -> Styled
<D
> {
70 self.actual
.paint(item
)
74 fn is_colored() -> bool
{
75 #[cfg(feature = "color")]
77 concolor
::get(concolor
::Stream
::Either
).ansi_color()
80 #[cfg(not(feature = "color"))]
86 pub(crate) use styled
::Style
;
87 pub use styled
::Styled
;
89 #[cfg(feature = "color")]
91 #[derive(Copy, Clone, Debug, Default)]
92 pub(crate) struct Style(pub(crate) yansi
::Style
);
95 pub(crate) fn paint
<T
: std
::fmt
::Display
>(self, item
: T
) -> Styled
<T
> {
96 Styled(self.0.paint(item
))
100 pub struct Styled
<D
: std
::fmt
::Display
>(yansi
::Paint
<D
>);
102 impl<D
: std
::fmt
::Display
> std
::fmt
::Display
for Styled
<D
> {
103 fn fmt(&self, f
: &mut std
::fmt
::Formatter
<'_
>) -> std
::fmt
::Result
{
109 #[cfg(not(feature = "color"))]
111 #[derive(Copy, Clone, Debug, Default)]
112 pub(crate) struct Style
;
115 pub(crate) fn paint
<T
: std
::fmt
::Display
>(self, item
: T
) -> Styled
<T
> {
120 pub struct Styled
<D
: std
::fmt
::Display
>(D
);
122 impl<D
: std
::fmt
::Display
> std
::fmt
::Display
for Styled
<D
> {
123 fn fmt(&self, f
: &mut std
::fmt
::Formatter
<'_
>) -> std
::fmt
::Result
{