Debian Codegraph @

src/color.rs

raw symbols SCIP
1 /// Any ANSI color code scheme
2 #[allow(clippy::exhaustive_enums)]
3 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
4 pub enum Colorrust-analyzer cargo anstyle 1.0.14 color/Color# {
5 /// Available 4-bit ANSI color palette codes
6 ///
7 /// The user's terminal defines the meaning of each palette code.
8 Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#),
9 /// 256 (8-bit) color support
10 ///
11 /// - `0..16` are [`AnsiColor`] palette codes
12 /// - `0..232` map to [`RgbColor`] color values
13 /// - `232..` map to [`RgbColor`] gray-scale values
14 Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color#),
15 /// 24-bit ANSI RGB color codes
16 Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor#),
17 }
18
19 impl Colorrust-analyzer cargo anstyle 1.0.14 color/Color# {
20 /// Create a [`Style`][crate::Style] with this as the foreground
21 #[inline]
22 pub fn onrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]on().(self, background: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Colorrust-analyzer cargo anstyle 1.0.14 color/Color#>) -> craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style# {
23 craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style#::newrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]new().()
24 .fg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]fg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self))
25 .bg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]bg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(background.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()))
26 }
27
28 /// Create a [`Style`][crate::Style] with this as the foreground
29 #[inline]
30 pub const fn on_defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]on_default().(self) -> craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style# {
31 craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style#::newrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]new().().fg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]fg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self))
32 }
33
34 /// Render the ANSI code for a foreground color
35 #[inline]
36 pub fn render_fgrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]render_fg().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
37 match self {
38 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(color) => color.as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_fg_buffer().(),
39 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(color) => color.as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_fg_buffer().(),
40 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(color) => color.as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_fg_buffer().(),
41 }
42 }
43
44 #[inline]
45 #[cfg(feature = "std")]
46 pub(craterust-analyzer cargo anstyle 1.0.14 crate/) fn write_fg_torust-analyzer cargo anstyle 1.0.14 color/impl#[Color]write_fg_to().(self, write: &mut dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
47 let buffer = match self {
48 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(color) => color.as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_fg_buffer().(),
49 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(color) => color.as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_fg_buffer().(),
50 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(color) => color.as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_fg_buffer().(),
51 };
52 buffer.write_torust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_to().(write)
53 }
54
55 /// Render the ANSI code for a background color
56 #[inline]
57 pub fn render_bgrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]render_bg().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
58 match self {
59 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(color) => color.as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_bg_buffer().(),
60 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(color) => color.as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_bg_buffer().(),
61 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(color) => color.as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_bg_buffer().(),
62 }
63 }
64
65 #[inline]
66 #[cfg(feature = "std")]
67 pub(craterust-analyzer cargo anstyle 1.0.14 crate/) fn write_bg_torust-analyzer cargo anstyle 1.0.14 color/impl#[Color]write_bg_to().(self, write: &mut dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
68 let buffer = match self {
69 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(color) => color.as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_bg_buffer().(),
70 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(color) => color.as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_bg_buffer().(),
71 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(color) => color.as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_bg_buffer().(),
72 };
73 buffer.write_torust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_to().(write)
74 }
75
76 #[inline]
77 pub(craterust-analyzer cargo anstyle 1.0.14 crate/) fn render_underlinerust-analyzer cargo anstyle 1.0.14 color/impl#[Color]render_underline().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
78 match self {
79 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(color) => color.as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_underline_buffer().(),
80 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(color) => color.as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_underline_buffer().(),
81 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(color) => color.as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_underline_buffer().(),
82 }
83 }
84
85 #[inline]
86 #[cfg(feature = "std")]
87 pub(craterust-analyzer cargo anstyle 1.0.14 crate/) fn write_underline_torust-analyzer cargo anstyle 1.0.14 color/impl#[Color]write_underline_to().(self, write: &mut dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
88 let buffer = match self {
89 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(color) => color.as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_underline_buffer().(),
90 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(color) => color.as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_underline_buffer().(),
91 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]::Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(color) => color.as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_underline_buffer().(),
92 };
93 buffer.write_torust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_to().(write)
94 }
95 }
96
97 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#> for Colorrust-analyzer cargo anstyle 1.0.14 color/Color# {
98 #[inline]
99 fn fromrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<AnsiColor>`]from().(inner: AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<AnsiColor>`] {
100 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<AnsiColor>`]::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(inner)
101 }
102 }
103
104 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color#> for Colorrust-analyzer cargo anstyle 1.0.14 color/Color# {
105 #[inline]
106 fn fromrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<Ansi256Color>`]from().(inner: Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color#) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<Ansi256Color>`] {
107 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<Ansi256Color>`]::Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(inner)
108 }
109 }
110
111 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor#> for Colorrust-analyzer cargo anstyle 1.0.14 color/Color# {
112 #[inline]
113 fn fromrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<RgbColor>`]from().(inner: RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor#) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<RgbColor>`] {
114 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<RgbColor>`]::Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(inner)
115 }
116 }
117
118 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<u8> for Colorrust-analyzer cargo anstyle 1.0.14 color/Color# {
119 #[inline]
120 fn fromrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<u8>`]from().(inner: u8) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<u8>`] {
121 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<u8>`]::Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(inner.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
122 }
123 }
124
125 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(u8, u8, u8)> for Colorrust-analyzer cargo anstyle 1.0.14 color/Color# {
126 #[inline]
127 fn fromrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<(u8, u8, u8)>`]from().(inner: (u8, u8, u8)) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<(u8, u8, u8)>`] {
128 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Color][`From<(u8, u8, u8)>`]::Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(inner.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
129 }
130 }
131
132 /// Available 4-bit ANSI color palette codes
133 ///
134 /// The user's terminal defines the meaning of each palette code.
135 #[allow(clippy::exhaustive_enums)]
136 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
137 #[repr(u8)]
138 pub enum AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor# {
139 /// Black: #0 (foreground code `30`, background code `40`).
140 Blackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Black#,
141
142 /// Red: #1 (foreground code `31`, background code `41`).
143 Redrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Red#,
144
145 /// Green: #2 (foreground code `32`, background code `42`).
146 Greenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Green#,
147
148 /// Yellow: #3 (foreground code `33`, background code `43`).
149 Yellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Yellow#,
150
151 /// Blue: #4 (foreground code `34`, background code `44`).
152 Bluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Blue#,
153
154 /// Magenta: #5 (foreground code `35`, background code `45`).
155 Magentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Magenta#,
156
157 /// Cyan: #6 (foreground code `36`, background code `46`).
158 Cyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Cyan#,
159
160 /// White: #7 (foreground code `37`, background code `47`).
161 Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White#,
162
163 /// Bright black: #0 (foreground code `90`, background code `100`).
164 BrightBlackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlack#,
165
166 /// Bright red: #1 (foreground code `91`, background code `101`).
167 BrightRedrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightRed#,
168
169 /// Bright green: #2 (foreground code `92`, background code `102`).
170 BrightGreenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightGreen#,
171
172 /// Bright yellow: #3 (foreground code `93`, background code `103`).
173 BrightYellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightYellow#,
174
175 /// Bright blue: #4 (foreground code `94`, background code `104`).
176 BrightBluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlue#,
177
178 /// Bright magenta: #5 (foreground code `95`, background code `105`).
179 BrightMagentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightMagenta#,
180
181 /// Bright cyan: #6 (foreground code `96`, background code `106`).
182 BrightCyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightCyan#,
183
184 /// Bright white: #7 (foreground code `97`, background code `107`).
185 BrightWhiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightWhite#,
186 }
187
188 impl AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor# {
189 /// Create a [`Style`][crate::Style] with this as the foreground
190 #[inline]
191 pub fn onrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]on().(self, background: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Colorrust-analyzer cargo anstyle 1.0.14 color/Color#>) -> craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style# {
192 craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style#::newrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]new().()
193 .fg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]fg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))
194 .bg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]bg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(background.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()))
195 }
196
197 /// Create a [`Style`][crate::Style] with this as the foreground
198 #[inline]
199 pub const fn on_defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]on_default().(self) -> craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style# {
200 craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style#::newrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]new().().fg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]fg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo anstyle 1.0.14 color/Color#::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(self)))
201 }
202
203 /// Render the ANSI code for a foreground color
204 #[inline]
205 pub fn render_fgrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]render_fg().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
206 NullFormatterrust-analyzer cargo anstyle 1.0.14 color/NullFormatter#(self.as_fg_strrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_fg_str().())
207 }
208
209 #[inline]
210 fn as_fg_strrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_fg_str().(&self) -> &'static str {
211 match self {
212 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Blackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Black# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("3", "0"),
213 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Redrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Red# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("3", "1"),
214 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Greenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Green# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("3", "2"),
215 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Yellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Yellow# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("3", "3"),
216 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Bluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Blue# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("3", "4"),
217 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Magentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Magenta# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("3", "5"),
218 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Cyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Cyan# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("3", "6"),
219 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("3", "7"),
220 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBlackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlack# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("9", "0"),
221 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightRedrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightRed# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("9", "1"),
222 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightGreenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightGreen# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("9", "2"),
223 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightYellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightYellow# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("9", "3"),
224 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlue# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("9", "4"),
225 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightMagentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightMagenta# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("9", "5"),
226 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightCyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightCyan# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("9", "6"),
227 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightWhiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightWhite# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("9", "7"),
228 }
229 }
230
231 #[inline]
232 fn as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_fg_buffer().(&self) -> DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
233 DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#::defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer][Default]default().().write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().(self.as_fg_strrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_fg_str().())
234 }
235
236 /// Render the ANSI code for a background color
237 #[inline]
238 pub fn render_bgrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]render_bg().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
239 NullFormatterrust-analyzer cargo anstyle 1.0.14 color/NullFormatter#(self.as_bg_strrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_bg_str().())
240 }
241
242 #[inline]
243 fn as_bg_strrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_bg_str().(&self) -> &'static str {
244 match self {
245 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Blackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Black# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("4", "0"),
246 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Redrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Red# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("4", "1"),
247 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Greenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Green# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("4", "2"),
248 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Yellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Yellow# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("4", "3"),
249 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Bluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Blue# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("4", "4"),
250 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Magentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Magenta# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("4", "5"),
251 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Cyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Cyan# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("4", "6"),
252 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("4", "7"),
253 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBlackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlack# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("10", "0"),
254 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightRedrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightRed# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("10", "1"),
255 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightGreenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightGreen# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("10", "2"),
256 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightYellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightYellow# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("10", "3"),
257 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlue# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("10", "4"),
258 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightMagentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightMagenta# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("10", "5"),
259 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightCyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightCyan# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("10", "6"),
260 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightWhiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightWhite# => escaperust-analyzer cargo anstyle 1.0.14 macros/escape!!("10", "7"),
261 }
262 }
263
264 #[inline]
265 fn as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_bg_buffer().(&self) -> DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
266 DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#::defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer][Default]default().().write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().(self.as_bg_strrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_bg_str().())
267 }
268
269 #[inline]
270 fn as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]as_underline_buffer().(&self) -> DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
271 // No per-color codes; must delegate to `Ansi256Color`
272 Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color#::fromrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color][`From<AnsiColor>`]from().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_underline_buffer().()
273 }
274
275 /// Change the color to/from bright
276 #[must_use]
277 #[inline]
278 pub fn brightrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]bright().(self, yes: bool) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor] {
279 if yes {
280 match self {
281 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Blackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Black# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBlackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlack#,
282 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Redrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Red# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightRedrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightRed#,
283 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Greenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Green# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightGreenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightGreen#,
284 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Yellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Yellow# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightYellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightYellow#,
285 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Bluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Blue# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlue#,
286 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Magentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Magenta# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightMagentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightMagenta#,
287 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Cyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Cyan# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightCyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightCyan#,
288 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightWhiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightWhite#,
289 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBlackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlack# => self,
290 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightRedrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightRed# => self,
291 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightGreenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightGreen# => self,
292 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightYellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightYellow# => self,
293 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlue# => self,
294 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightMagentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightMagenta# => self,
295 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightCyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightCyan# => self,
296 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightWhiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightWhite# => self,
297 }
298 } else {
299 match self {
300 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Blackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Black# => self,
301 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Redrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Red# => self,
302 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Greenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Green# => self,
303 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Yellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Yellow# => self,
304 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Bluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Blue# => self,
305 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Magentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Magenta# => self,
306 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Cyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Cyan# => self,
307 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White# => self,
308 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBlackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlack# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Blackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Black#,
309 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightRedrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightRed# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Redrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Red#,
310 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightGreenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightGreen# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Greenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Green#,
311 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightYellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightYellow# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Yellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Yellow#,
312 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlue# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Bluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Blue#,
313 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightMagentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightMagenta# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Magentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Magenta#,
314 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightCyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightCyan# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Cyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Cyan#,
315 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightWhiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightWhite# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White#,
316 }
317 }
318 }
319
320 /// Report whether the color is bright
321 #[inline]
322 pub fn is_brightrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]is_bright().(self) -> bool {
323 match self {
324 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Blackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Black# => false,
325 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Redrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Red# => false,
326 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Greenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Green# => false,
327 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Yellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Yellow# => false,
328 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Bluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Blue# => false,
329 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Magentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Magenta# => false,
330 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Cyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Cyan# => false,
331 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White# => false,
332 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBlackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlack# => true,
333 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightRedrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightRed# => true,
334 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightGreenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightGreen# => true,
335 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightYellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightYellow# => true,
336 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightBluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlue# => true,
337 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightMagentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightMagenta# => true,
338 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightCyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightCyan# => true,
339 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]::BrightWhiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightWhite# => true,
340 }
341 }
342 }
343
344 /// 256 (8-bit) color support
345 ///
346 /// - `0..16` are [`AnsiColor`] palette codes
347 /// - `0..232` map to [`RgbColor`] color values
348 /// - `232..` map to [`RgbColor`] gray-scale values
349 #[allow(clippy::exhaustive_structs)]
350 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
351 #[repr(transparent)]
352 pub struct Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color#(pub u8);
353
354 impl Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color# {
355 /// Create a [`Style`][crate::Style] with this as the foreground
356 #[inline]
357 pub fn onrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]on().(self, background: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Colorrust-analyzer cargo anstyle 1.0.14 color/Color#>) -> craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style# {
358 craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style#::newrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]new().()
359 .fg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]fg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))
360 .bg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]bg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(background.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()))
361 }
362
363 /// Create a [`Style`][crate::Style] with this as the foreground
364 #[inline]
365 pub const fn on_defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]on_default().(self) -> craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style# {
366 craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style#::newrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]new().().fg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]fg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo anstyle 1.0.14 color/Color#::Ansi256rust-analyzer cargo anstyle 1.0.14 color/Color#Ansi256#(self)))
367 }
368
369 /// Get the raw value
370 #[inline]
371 pub const fn indexrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]index().(self) -> u8 {
372 self.0rust-analyzer cargo anstyle 1.0.14 color/Ansi256Color#0.
373 }
374
375 /// Convert to [`AnsiColor`] when there is a 1:1 mapping
376 #[inline]
377 pub const fn into_ansirust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]into_ansi().(self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#> {
378 match self.indexrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]index().() {
379 0 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Blackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Black#),
380 1 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Redrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Red#),
381 2 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Greenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Green#),
382 3 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Yellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Yellow#),
383 4 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Bluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Blue#),
384 5 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Magentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Magenta#),
385 6 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Cyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Cyan#),
386 7 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White#),
387 8 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightBlackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlack#),
388 9 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightRedrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightRed#),
389 10 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightGreenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightGreen#),
390 11 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightYellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightYellow#),
391 12 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightBluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlue#),
392 13 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightMagentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightMagenta#),
393 14 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightCyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightCyan#),
394 15 => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightWhiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightWhite#),
395 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
396 }
397 }
398
399 /// Losslessly convert from [`AnsiColor`]
400 #[inline]
401 pub const fn from_ansirust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]from_ansi().(color: AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color] {
402 match color {
403 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Blackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Black# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](0),
404 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Redrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Red# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](1),
405 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Greenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Green# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](2),
406 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Yellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Yellow# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](3),
407 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Bluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Blue# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](4),
408 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Magentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Magenta# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](5),
409 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Cyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#Cyan# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](6),
410 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](7),
411 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightBlackrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlack# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](8),
412 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightRedrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightRed# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](9),
413 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightGreenrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightGreen# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](10),
414 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightYellowrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightYellow# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](11),
415 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightBluerust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightBlue# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](12),
416 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightMagentarust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightMagenta# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](13),
417 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightCyanrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightCyan# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](14),
418 AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::BrightWhiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#BrightWhite# => Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color](15),
419 }
420 }
421
422 /// Render the ANSI code for a foreground color
423 #[inline]
424 pub fn render_fgrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]render_fg().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
425 self.as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_fg_buffer().()
426 }
427
428 #[inline]
429 fn as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_fg_buffer().(&self) -> DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
430 DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#::defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer][Default]default().()
431 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("\x1B[38;5;")
432 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.indexrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]index().())
433 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("m")
434 }
435
436 /// Render the ANSI code for a background color
437 #[inline]
438 pub fn render_bgrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]render_bg().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
439 self.as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_bg_buffer().()
440 }
441
442 #[inline]
443 fn as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_bg_buffer().(&self) -> DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
444 DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#::defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer][Default]default().()
445 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("\x1B[48;5;")
446 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.indexrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]index().())
447 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("m")
448 }
449
450 #[inline]
451 fn as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]as_underline_buffer().(&self) -> DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
452 DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#::defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer][Default]default().()
453 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("\x1B[58;5;")
454 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.indexrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]index().())
455 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("m")
456 }
457 }
458
459 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<u8> for Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color# {
460 #[inline]
461 fn fromrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color][`From<u8>`]from().(inner: u8) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color][`From<u8>`] {
462 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color][`From<u8>`](inner)
463 }
464 }
465
466 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#> for Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color# {
467 #[inline]
468 fn fromrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color][`From<AnsiColor>`]from().(inner: AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color][`From<AnsiColor>`] {
469 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color][`From<AnsiColor>`]::from_ansirust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]from_ansi().(inner)
470 }
471 }
472
473 /// 24-bit ANSI RGB color codes
474 #[allow(clippy::exhaustive_structs)]
475 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)]
476 pub struct RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor#(pub u8, pub u8, pub u8);
477
478 impl RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor# {
479 /// Create a [`Style`][crate::Style] with this as the foreground
480 #[inline]
481 pub fn onrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]on().(self, background: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Colorrust-analyzer cargo anstyle 1.0.14 color/Color#>) -> craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style# {
482 craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style#::newrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]new().()
483 .fg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]fg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))
484 .bg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]bg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(background.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().()))
485 }
486
487 /// Create a [`Style`][crate::Style] with this as the foreground
488 #[inline]
489 pub const fn on_defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]on_default().(self) -> craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style# {
490 craterust-analyzer cargo anstyle 1.0.14 crate/::Stylerust-analyzer cargo anstyle 1.0.14 style/Style#::newrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]new().().fg_colorrust-analyzer cargo anstyle 1.0.14 style/impl#[Style]fg_color().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Colorrust-analyzer cargo anstyle 1.0.14 color/Color#::Rgbrust-analyzer cargo anstyle 1.0.14 color/Color#Rgb#(self)))
491 }
492
493 /// Red
494 #[inline]
495 pub const fn rrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]r().(self) -> u8 {
496 self.0rust-analyzer cargo anstyle 1.0.14 color/RgbColor#0.
497 }
498
499 /// Green
500 #[inline]
501 pub const fn grust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]g().(self) -> u8 {
502 self.1rust-analyzer cargo anstyle 1.0.14 color/RgbColor#1.
503 }
504
505 /// Blue
506 #[inline]
507 pub const fn brust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]b().(self) -> u8 {
508 self.2rust-analyzer cargo anstyle 1.0.14 color/RgbColor#2.
509 }
510
511 /// Render the ANSI code for a foreground color
512 #[inline]
513 pub fn render_fgrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]render_fg().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
514 self.as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_fg_buffer().()
515 }
516
517 #[inline]
518 fn as_fg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_fg_buffer().(&self) -> DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
519 DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#::defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer][Default]default().()
520 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("\x1B[38;2;")
521 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.rrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]r().())
522 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().(";")
523 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.grust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]g().())
524 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().(";")
525 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.brust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]b().())
526 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("m")
527 }
528
529 /// Render the ANSI code for a background color
530 #[inline]
531 pub fn render_bgrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]render_bg().(self) -> impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# {
532 self.as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_bg_buffer().()
533 }
534
535 #[inline]
536 fn as_bg_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_bg_buffer().(&self) -> DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
537 DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#::defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer][Default]default().()
538 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("\x1B[48;2;")
539 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.rrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]r().())
540 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().(";")
541 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.grust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]g().())
542 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().(";")
543 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.brust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]b().())
544 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("m")
545 }
546
547 #[inline]
548 fn as_underline_bufferrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]as_underline_buffer().(&self) -> DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
549 DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#::defaultrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer][Default]default().()
550 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("\x1B[58;2;")
551 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.rrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]r().())
552 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().(";")
553 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.grust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]g().())
554 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().(";")
555 .write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(self.brust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]b().())
556 .write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().("m")
557 }
558 }
559
560 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<(u8, u8, u8)> for RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor# {
561 #[inline]
562 fn fromrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor][`From<(u8, u8, u8)>`]from().(inner: (u8, u8, u8)) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor][`From<(u8, u8, u8)>`] {
563 let (r, g, b) = inner;
564 Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor][`From<(u8, u8, u8)>`](r, g, b)
565 }
566 }
567
568 const DISPLAY_BUFFER_CAPACITYrust-analyzer cargo anstyle 1.0.14 color/DISPLAY_BUFFER_CAPACITY.: usize = 19;
569
570 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
571 struct DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
572 bufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#buffer.: [u8; DISPLAY_BUFFER_CAPACITYrust-analyzer cargo anstyle 1.0.14 color/DISPLAY_BUFFER_CAPACITY.],
573 lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len.: usize,
574 }
575
576 impl DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
577 #[must_use]
578 #[inline(never)]
579 fn write_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_str().(mut self, part: &'static str) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer] {
580 for (i, b) in part.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().().iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
581 self.bufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#buffer.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().self.lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().b;
582 }
583 self.lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().part.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().();
584 self
585 }
586
587 #[must_use]
588 #[inline(never)]
589 fn write_coderust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_code().(mut self, code: u8) -> Selfrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer] {
590 let c1: u8 = (code rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Div<Self>`]div().100) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem().10;
591 let c2: u8 = (code rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Div<Self>`]div().10) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem().10;
592 let c3: u8 = code rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Rem<Self>`]rem().10;
593
594 let mut printed = false;
595 if c1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0 {
596 printed = true;
597 self.bufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#buffer.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().self.lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = b'0' rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().c1;
598 self.lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
599 }
600 if c2 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0 || printed {
601 self.bufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#buffer.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().self.lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = b'0' rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().c2;
602 self.lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
603 }
604 // If we received a zero value we must still print a value.
605 self.bufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#buffer.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().self.lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = b'0' rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().c3;
606 self.lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
607
608 self
609 }
610
611 #[inline]
612 fn as_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]as_str().(&self) -> &str {
613 // SAFETY: Only `&str` can be written to the buffer
614 #[allow(unsafe_code)]
615 unsafe {
616 corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::from_utf8_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8_unchecked().(&self.bufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#buffer.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#self.lenrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#len.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().)
617 }
618 }
619
620 #[inline]
621 #[cfg(feature = "std")]
622 fn write_torust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]write_to().(self, write: &mut dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
623 write.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(self.as_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]as_str().().as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().())
624 }
625 }
626
627 impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer# {
628 #[inline]
629 fn fmtrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer][Display]fmt().(&self, f: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
630 f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(self.as_strrust-analyzer cargo anstyle 1.0.14 color/impl#[DisplayBuffer]as_str().())
631 }
632 }
633
634 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
635 struct NullFormatterrust-analyzer cargo anstyle 1.0.14 color/NullFormatter#(&'static str);
636
637 impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for NullFormatterrust-analyzer cargo anstyle 1.0.14 color/NullFormatter# {
638 #[inline]
639 fn fmtrust-analyzer cargo anstyle 1.0.14 color/impl#[NullFormatter][Display]fmt().(&self, f: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
640 f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(self.0rust-analyzer cargo anstyle 1.0.14 color/NullFormatter#0.)
641 }
642 }
643
644 #[cfg(test)]
645 #[cfg(feature = "std")]
646 mod testrust-analyzer cargo anstyle 1.0.14 color/test/ {
647 use superrust-analyzer cargo anstyle 1.0.14 color/::*;
648
649 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
650 fn max_display_bufferrust-analyzer cargo anstyle 1.0.14 color/test/max_display_buffer().() {
651 let c = RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor#(255, 255, 255);
652 let actual = c.render_fgrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]render_fg().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
653 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(actual, "\u{1b}[38;2;255;255;255m");
654 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(actual.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().(), DISPLAY_BUFFER_CAPACITYrust-analyzer cargo anstyle 1.0.14 color/DISPLAY_BUFFER_CAPACITY.);
655 }
656
657 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
658 fn print_size_ofrust-analyzer cargo anstyle 1.0.14 color/test/print_size_of().() {
659 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().;
660 dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<Colorrust-analyzer cargo anstyle 1.0.14 color/Color#>());
661 dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#>());
662 dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color#>());
663 dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor#>());
664 dbgrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/dbg!!(size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<DisplayBufferrust-analyzer cargo anstyle 1.0.14 color/DisplayBuffer#>());
665 }
666
667 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
668 fn no_alignrust-analyzer cargo anstyle 1.0.14 color/test/no_align().() {
669 #[track_caller]
670 fn assert_no_alignrust-analyzer cargo anstyle 1.0.14 color/test/assert_no_align().(d: impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#) {
671 let expected = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{d}");
672 let actual = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{d:<10}");
673 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(expected, actual);
674 }
675
676 assert_no_alignrust-analyzer cargo anstyle 1.0.14 color/test/assert_no_align().(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White#.render_fgrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]render_fg().());
677 assert_no_alignrust-analyzer cargo anstyle 1.0.14 color/test/assert_no_align().(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White#.render_bgrust-analyzer cargo anstyle 1.0.14 color/impl#[AnsiColor]render_bg().());
678 assert_no_alignrust-analyzer cargo anstyle 1.0.14 color/test/assert_no_align().(Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color#(0).render_fgrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]render_fg().());
679 assert_no_alignrust-analyzer cargo anstyle 1.0.14 color/test/assert_no_align().(Ansi256Colorrust-analyzer cargo anstyle 1.0.14 color/Ansi256Color#(0).render_bgrust-analyzer cargo anstyle 1.0.14 color/impl#[Ansi256Color]render_bg().());
680 assert_no_alignrust-analyzer cargo anstyle 1.0.14 color/test/assert_no_align().(RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor#(0, 0, 0).render_fgrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]render_fg().());
681 assert_no_alignrust-analyzer cargo anstyle 1.0.14 color/test/assert_no_align().(RgbColorrust-analyzer cargo anstyle 1.0.14 color/RgbColor#(0, 0, 0).render_bgrust-analyzer cargo anstyle 1.0.14 color/impl#[RgbColor]render_bg().());
682 assert_no_alignrust-analyzer cargo anstyle 1.0.14 color/test/assert_no_align().(Colorrust-analyzer cargo anstyle 1.0.14 color/Color#::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White#).render_fgrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]render_fg().());
683 assert_no_alignrust-analyzer cargo anstyle 1.0.14 color/test/assert_no_align().(Colorrust-analyzer cargo anstyle 1.0.14 color/Color#::Ansirust-analyzer cargo anstyle 1.0.14 color/Color#Ansi#(AnsiColorrust-analyzer cargo anstyle 1.0.14 color/AnsiColor#::Whiterust-analyzer cargo anstyle 1.0.14 color/AnsiColor#White#).render_bgrust-analyzer cargo anstyle 1.0.14 color/impl#[Color]render_bg().());
684 }
685 }