Debian Codegraph @

src/rgb/rgb.rs

raw symbols SCIP
1 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{
2 anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/::TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#,
3 fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/,
4 fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
5 markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
6 numrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/::ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#,
7 opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#, Divrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#},
8 strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#,
9 };
10
11 use craterust-analyzer cargo palette 0.7.6 crate/::{
12 alpharust-analyzer cargo palette 0.7.6 alpha/::Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#,
13 anglerust-analyzer cargo palette 0.7.6 angle/::{RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#, UnsignedAnglerust-analyzer cargo palette 0.7.6 angle/UnsignedAngle#},
14 bool_maskrust-analyzer cargo palette 0.7.6 bool_mask/::{BitOpsrust-analyzer cargo palette 0.7.6 bool_mask/BitOps#, HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#, LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#},
15 castrust-analyzer cargo palette 0.7.6 cast/::{ComponentOrderrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#, Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#},
16 color_differencerust-analyzer cargo palette 0.7.6 color_difference/::Wcag21RelativeContrastrust-analyzer cargo palette 0.7.6 color_difference/Wcag21RelativeContrast#,
17 convertrust-analyzer cargo palette 0.7.6 convert/::{FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#, IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#},
18 encodingrust-analyzer cargo palette 0.7.6 encoding/::{FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#, IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#, Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#, Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#},
19 lumarust-analyzer cargo palette 0.7.6 luma/::LumaStandardrust-analyzer cargo palette 0.7.6 luma/LumaStandard#,
20 matrixrust-analyzer cargo palette 0.7.6 matrix/::{matrix_inverserust-analyzer cargo palette 0.7.6 matrix/matrix_inverse()., matrix_maprust-analyzer cargo palette 0.7.6 matrix/matrix_map()., multiply_xyz_to_rgbrust-analyzer cargo palette 0.7.6 matrix/multiply_xyz_to_rgb()., rgb_to_xyz_matrixrust-analyzer cargo palette 0.7.6 matrix/rgb_to_xyz_matrix().},
21 numrust-analyzer cargo palette 0.7.6 num/::{
22 Absrust-analyzer cargo palette 0.7.6 num/Abs#, Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#, FromScalarrust-analyzer cargo palette 0.7.6 num/FromScalar#, IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#, MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#, Onerust-analyzer cargo palette 0.7.6 num/One#, PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#, Realrust-analyzer cargo palette 0.7.6 num/Real#, Reciprust-analyzer cargo palette 0.7.6 num/Recip#, Roundrust-analyzer cargo palette 0.7.6 num/Round#,
23 Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry#, Zerorust-analyzer cargo palette 0.7.6 num/Zero#,
24 },
25 oklabrust-analyzer cargo palette 0.7.6 oklab/::oklab_to_linear_srgbrust-analyzer cargo palette 0.7.6 oklab/oklab_to_linear_srgb().,
26 rgbrust-analyzer cargo palette 0.7.6 rgb/::{RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#},
27 stimulusrust-analyzer cargo palette 0.7.6 stimulus/::{FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#, Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#, StimulusColorrust-analyzer cargo palette 0.7.6 stimulus/StimulusColor#},
28 white_pointrust-analyzer cargo palette 0.7.6 white_point/::{Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#, D65rust-analyzer cargo palette 0.7.6 white_point/D65#},
29 FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#, GetHuerust-analyzer cargo palette 0.7.6 GetHue#, Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#, Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#, IntoColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/IntoColor#, Lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#, Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#, RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#, Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#, Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#,
30 };
31
32 use superrust-analyzer cargo palette 0.7.6 rgb/::Primariesrust-analyzer cargo palette 0.7.6 rgb/Primaries#;
33
34 /// Generic RGB with an alpha component. See the [`Rgba` implementation in
35 /// `Alpha`](crate::Alpha#Rgba).
36 pub type Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S = Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T = f32> = Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>, T>;
37
38 /// Generic RGB.
39 ///
40 /// RGB is probably the most common color space, when it comes to computer
41 /// graphics, and it's defined as an additive mixture of red, green and blue
42 /// light, where gray scale colors are created when these three channels are
43 /// equal in strength.
44 ///
45 /// # Creating a Value
46 ///
47 /// RGB comes in different shapes and formats. You will probably want to start
48 /// with either the [`Srgb`](crate::Srgb) or [`Srgba`](crate::Srgba) alias,
49 /// which represents the common sRGB format that most images and tools use.
50 /// Then, depending on your input, you can either just call [`new`](Rgb::new) or
51 /// convert from another data format.
52 ///
53 /// ```
54 /// use palette::Srgb;
55 ///
56 /// let rgb_u8 = Srgb::new(171u8, 193, 35);
57 /// let rgb_f32 = Srgb::new(0.3f32, 0.8, 0.1);
58 ///
59 /// // `new` is also `const`:
60 /// const RGB_U8: Srgb<u8> = Srgb::new(171, 193, 35);
61 ///
62 /// // Converting from one number format to another can be as simple as this:
63 /// let rgb_u8_from_f32_1: Srgb<u8> = Srgb::new(0.3f32, 0.8, 0.1).into();
64 ///
65 /// // ...or more explicitly like this:
66 /// let rgb_u8_from_f32_2 = Srgb::new(0.3f32, 0.8, 0.1).into_format::<u8>();
67 ///
68 /// // Hexadecimal is also supported, with or without the #:
69 /// let rgb_from_hex1: Srgb<u8> = "#f034e6".parse().unwrap();
70 /// let rgb_from_hex2: Srgb<u8> = "f034e6".parse().unwrap();
71 /// assert_eq!(rgb_from_hex1, rgb_from_hex2);
72 ///
73 /// // This includes the shorthand format:
74 /// let rgb_from_short_hex: Srgb<u8> = "f3e".parse().unwrap();
75 /// let rgb_from_long_hex: Srgb<u8> = "ff33ee".parse().unwrap();
76 /// assert_eq!(rgb_from_short_hex, rgb_from_long_hex);
77 ///
78 /// // It's also possible to convert from (and to) arrays, tuples and `u32` values:
79 /// let rgb_from_array = Srgb::from([171u8, 193, 35]);
80 /// let rgb_from_tuple = Srgb::from((171u8, 193, 35));
81 /// let rgb_from_u32 = Srgb::from(0x607F00);
82 /// ```
83 ///
84 /// # Linear, sRGB and Gamma Correction
85 ///
86 /// Many conversions and operations on RGB require that it's linear, meaning
87 /// that gamma correction is required when converting to and from displayable
88 /// RGB, such as sRGB. It's common to store and send RGB values where the
89 /// numbers are on a non-linear scale. In a non-linear format, a value of, for
90 /// example, 0.5 would not represent a light intensity of 50%, which makes some
91 /// operations (such as blurring) give incorrect results.
92 ///
93 /// You will probably encounter or use [`LinSrgb`](crate::LinSrgb) or
94 /// [`LinSrgba`](crate::LinSrgba) at some point. These are aliases for linear
95 /// sRGB and would usually be obtained by converting an [`Srgb`] value with
96 /// [`into_linear`](Rgb::into_linear).
97 ///
98 /// ```no_run
99 /// use palette::{LinSrgb, Srgb};
100 ///
101 /// // This function uses linear sRGB for something. But how do we interface with it?
102 /// fn uses_linear_srgb(input: LinSrgb<f32>) -> LinSrgb<f32> { todo!() }
103 ///
104 /// // Linear sRGB will usually be created from non-linear sRGB:
105 /// let output = uses_linear_srgb(Srgb::new(0.3, 0.8, 0.1).into_linear());
106 ///
107 /// // It's also possible to convert directly from u8 to f32 for sRGB.
108 /// // This is much faster than using `into_format` first:
109 /// let output = uses_linear_srgb(Srgb::new(171u8, 193, 35).into_linear());
110 ///
111 /// // Converting the output back to `Srgb<u8>` (or `Srgb<f32>`) is just as simple:
112 /// let output_u8 = Srgb::<u8>::from_linear(output);
113 /// // ..or:
114 /// let output_u8: Srgb<u8> = output.into_encoding();
115 /// ```
116 ///
117 /// It's of course also possible to create a linear value from constants, but
118 /// it's not necessarily as intuitive. It's best to avoid storing them as
119 /// `LinSrgb<u8>` (or `LinRgb<_, u8>`) values, to avoid banding among dark
120 /// colors.
121 ///
122 /// See the [`encoding`](crate::encoding) module for built-in encoding formats.
123 ///
124 /// # Storage Formats and Pixel Buffers
125 ///
126 /// It's common to read and write RGB values as bytes, hexadecimal strings, or
127 /// sometimes `u32` values. A single RGB value can be converted to all of these
128 /// formats and more.
129 ///
130 /// ```no_run
131 /// use palette::{Srgb, LinSrgb};
132 ///
133 /// let source: LinSrgb<f32> = todo!();
134 ///
135 /// let u8_array: [u8; 3] = Srgb::from_linear(source).into();
136 /// let hex_string1 = format!("#{:x}", Srgb::<u8>::from_linear(source)); // The # is optional.
137 /// let u32_value: u32 = Srgb::from_linear(source).into();
138 /// ```
139 ///
140 /// It's also possible to control the component order.
141 /// [`PackedArgb`](crate::rgb::PackedArgb) is one of a few aliases for
142 /// [`Packed`], which represents a color that has been "packed" into a specific
143 /// data format. This can be a `u32` or `[u8; 4]`, for example. This is helpful
144 /// for reading and writing colors with a different order than the default RGBA.
145 ///
146 /// ```no_run
147 /// use palette::{rgb::PackedArgb, Srgba, LinSrgba};
148 ///
149 /// let source: LinSrgba<f32> = todo!();
150 ///
151 /// let u8_array: [u8; 4] = PackedArgb::from(Srgba::from_linear(source)).into();
152 /// let u32_value: u32 = PackedArgb::from(Srgba::from_linear(source)).into();
153 /// ```
154 ///
155 /// If you need to work with colors in a byte buffer, such as `[u8]`, `Vec<u8>`
156 /// or the `image` crate, there's a quick way to borrow that buffer as a slice
157 /// of RGB(A) colors. The [`cast`](crate::cast) module has a number of traits
158 /// and functions for casting values without copying them.
159 ///
160 /// ```no_run
161 /// use image::RgbImage;
162 /// use palette::{cast::ComponentsAsMut, Srgb};
163 ///
164 /// let mut image: RgbImage = todo!();
165 /// let pixels: &mut [Srgb<u8>] = image.components_as_mut();
166 ///
167 /// for pixel in pixels {
168 /// std::mem::swap(&mut pixel.red, &mut pixel.blue);
169 /// }
170 /// ```
171 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, ArrayCastrust-analyzer cargo palette_derive 0.7.6 ArrayCast:, FromColorUnclampedrust-analyzer cargo palette_derive 0.7.6 FromColorUnclamped:, WithAlpharust-analyzer cargo palette_derive 0.7.6 WithAlpha:)]
172 #[cfg_attr(feature = "serializing", derive(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:))]
173 #[palette(
174 palette_internal,
175 rgb_standard = "S",
176 component = "T",
177 skip_derives(Xyz, Hsv, Hsl, Luma, Rgb, Oklab)
178 )]
179 #[repr(C)]
180 pub struct Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S = Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, T = f32> {
181 /// The amount of red light, where 0.0 is no red light and 1.0 (or 255u8) is
182 /// the highest displayable amount.
183 pub redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.: T,
184
185 /// The amount of green light, where 0.0 is no green light and 1.0 (or
186 /// 255u8) is the highest displayable amount.
187 pub greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.: T,
188
189 /// The amount of blue light, where 0.0 is no blue light and 1.0 (or 255u8)
190 /// is the highest displayable amount.
191 pub bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.: T,
192
193 /// The kind of RGB standard. sRGB is the default.
194 #[cfg_attr(feature = "serializing", serde(skip))]
195 #[paletterust-analyzer cargo palette_derive 0.7.6 palette:(unsafe_zero_sized)]
196 pub standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<S>,
197 }
198
199 impl<S, T> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T> {
200 /// Create an RGB color.
201 ///
202 /// It's possible to create a color in one number format and convert it to
203 /// another format with either [`into_format`](Rgb::into_format) or
204 /// [`into_linear`](Rgb::into_linear).
205 ///
206 /// ```
207 /// use palette::{Srgb, LinSrgb};
208 ///
209 /// // Changes only the number format:
210 /// let rgb_f32: Srgb<f32> = Srgb::new(171u8, 193, 35).into_format();
211 ///
212 /// // Changes the number format and converts to linear in one go.
213 /// // This is faster than `.into_format().into_linear()`:
214 /// let linear: LinSrgb<f32> = Srgb::new(171u8, 193, 35).into_linear();
215 /// ```
216 pub const fn newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(red: T, green: T, blue: T) -> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T> {
217 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb# {
218 redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.,
219 greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.,
220 bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.,
221 standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
222 }
223 }
224
225 /// Convert the RGB components into another number type.
226 ///
227 /// ```
228 /// use palette::Srgb;
229 ///
230 /// let rgb_u8: Srgb<u8> = Srgb::new(0.3, 0.7, 0.2).into_format();
231 /// ```
232 ///
233 /// See also [`into_linear`](Rgb::into_linear) and
234 /// [`into_encoding`](Rgb::into_encoding) for a faster option if you need to
235 /// change between linear and non-linear encoding at the same time.
236 pub fn into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().<U>(self) -> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, U>
237 where
238 U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T>,
239 {
240 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb# {
241 redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.),
242 greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.),
243 bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.: U::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.),
244 standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
245 }
246 }
247
248 /// Convert the RGB components from another number type.
249 ///
250 /// ```
251 /// use palette::Srgb;
252 ///
253 /// let rgb_u8 = Srgb::<u8>::from_format(Srgb::new(0.3, 0.7, 0.2));
254 /// ```
255 ///
256 /// See also [`from_linear`](Rgb::from_linear) and
257 /// [`from_encoding`](Rgb::from_encoding) for a faster option if you need to
258 /// change between linear and non-linear encoding at the same time.
259 pub fn from_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]from_format().<U>(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, U>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]
260 where
261 T: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<U>,
262 {
263 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().()
264 }
265
266 /// Convert to a `(red, green, blue)` tuple.
267 pub fn into_componentsrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_components().(self) -> (T, T, T) {
268 (self.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., self.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., self.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.)
269 }
270
271 /// Convert from a `(red, green, blue)` tuple.
272 pub fn from_componentsrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]from_components().((red, green, blue): (T, T, T)) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`] {
273 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(red, green, blue)
274 }
275 }
276
277 impl<S, T> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
278 where
279 T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#,
280 {
281 /// Return the `red` value minimum.
282 pub fn min_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_red().() -> T {
283 T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()
284 }
285
286 /// Return the `red` value maximum.
287 pub fn max_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_red().() -> T {
288 T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().()
289 }
290
291 /// Return the `green` value minimum.
292 pub fn min_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_green().() -> T {
293 T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()
294 }
295
296 /// Return the `green` value maximum.
297 pub fn max_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_green().() -> T {
298 T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().()
299 }
300
301 /// Return the `blue` value minimum.
302 pub fn min_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_blue().() -> T {
303 T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()
304 }
305
306 /// Return the `blue` value maximum.
307 pub fn max_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_blue().() -> T {
308 T::max_intensityrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#max_intensity().()
309 }
310 }
311
312 impl<S> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8> {
313 /// Convert to a packed `u32` with with specifiable component order.
314 ///
315 /// ```
316 /// use palette::{rgb, Srgb};
317 ///
318 /// let integer = Srgb::new(96u8, 127, 0).into_u32::<rgb::channels::Rgba>();
319 /// assert_eq!(0x607F00FF, integer);
320 /// ```
321 ///
322 /// It's also possible to use `From` and `Into`, which defaults to the
323 /// `0xAARRGGBB` component order:
324 ///
325 /// ```
326 /// use palette::Srgb;
327 ///
328 /// let integer = u32::from(Srgb::new(96u8, 127, 0));
329 /// assert_eq!(0xFF607F00, integer);
330 /// ```
331 ///
332 /// See [Packed](crate::cast::Packed) for more details.
333 #[inline]
334 pub fn into_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`]into_u32().<O>(self) -> u32
335 where
336 O: ComponentOrderrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>, u32>,
337 {
338 O::packrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#pack().(Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::fromrust-analyzer cargo palette 0.7.6 alpha/alpha/impl#[`Alpha<C, T>`][`From<C>`]from().(self))
339 }
340
341 /// Convert from a packed `u32` with specifiable component order.
342 ///
343 /// ```
344 /// use palette::{rgb, Srgb};
345 ///
346 /// let rgb = Srgb::from_u32::<rgb::channels::Rgba>(0x607F00FF);
347 /// assert_eq!(Srgb::new(96u8, 127, 0), rgb);
348 /// ```
349 ///
350 /// It's also possible to use `From` and `Into`, which defaults to the
351 /// `0xAARRGGBB` component order:
352 ///
353 /// ```
354 /// use palette::Srgb;
355 ///
356 /// let rgb = Srgb::from(0x607F00);
357 /// assert_eq!(Srgb::new(96u8, 127, 0), rgb);
358 /// ```
359 ///
360 /// See [Packed](crate::cast::Packed) for more details.
361 #[inline]
362 pub fn from_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`]from_u32().<O>(color: u32) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`]
363 where
364 O: ComponentOrderrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>, u32>,
365 {
366 O::unpackrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#unpack().(color).colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.
367 }
368 }
369
370 impl<S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#, T> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T> {
371 /// Convert the color to linear RGB.
372 ///
373 /// Some transfer functions allow the component type to be converted at the
374 /// same time. This is usually offered with increased performance, compared
375 /// to using [`into_format`][Rgb::into_format].
376 ///
377 /// ```
378 /// use palette::{Srgb, LinSrgb};
379 ///
380 /// let linear: LinSrgb<f32> = Srgb::new(96u8, 127, 0).into_linear();
381 /// ```
382 ///
383 /// See the transfer function types in the [`encoding`](crate::encoding)
384 /// module for details and performance characteristics.
385 #[inline(always)]
386 pub fn into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_linear().<U>(self) -> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#>, U>
387 where
388 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<U, T>,
389 {
390 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(
391 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#::into_linearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#into_linear().(self.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.),
392 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#::into_linearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#into_linear().(self.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.),
393 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#::into_linearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#into_linear().(self.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.),
394 )
395 }
396
397 /// Convert linear RGB to non-linear RGB.
398 ///
399 /// Some transfer functions allow the component type to be converted at the
400 /// same time. This is usually offered with increased performance, compared
401 /// to using [`into_format`][Rgb::into_format].
402 ///
403 /// ```
404 /// use palette::{Srgb, LinSrgb};
405 ///
406 /// let encoded = Srgb::<u8>::from_linear(LinSrgb::new(0.95f32, 0.90, 0.30));
407 /// ```
408 ///
409 /// See the transfer function types in the [`encoding`](crate::encoding)
410 /// module for details and performance characteristics.
411 #[inline(always)]
412 pub fn from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]from_linear().<U>(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#>, U>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]
413 where
414 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<U, T>,
415 {
416 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(
417 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#::from_linearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#from_linear().(color.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.),
418 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#::from_linearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#from_linear().(color.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.),
419 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#::from_linearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#from_linear().(color.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.),
420 )
421 }
422 }
423
424 impl<S: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, T> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<S>, T> {
425 /// Convert a linear color to a different encoding.
426 ///
427 /// Some transfer functions allow the component type to be converted at the
428 /// same time. This is usually offered with increased performance, compared
429 /// to using [`into_format`][Rgb::into_format].
430 ///
431 /// ```
432 /// use palette::{Srgb, LinSrgb};
433 ///
434 /// let encoded: Srgb<u8> = LinSrgb::new(0.95f32, 0.90, 0.30).into_encoding();
435 /// ```
436 ///
437 /// See the transfer function types in the [`encoding`](crate::encoding)
438 /// module for details and performance characteristics.
439 pub fn into_encodingrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<Linear<S>, T>`]into_encoding().<U, St>(self) -> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<St, U>
440 where
441 St: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = S>,
442 St::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, U>,
443 {
444 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<St, U>::from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]from_linear().(self)
445 }
446
447 /// Convert linear RGB from a different encoding.
448 ///
449 /// Some transfer functions allow the component type to be converted at the
450 /// same time. This is usually offered with increased performance, compared
451 /// to using [`into_format`][Rgb::into_format].
452 ///
453 /// ```
454 /// use palette::{Srgb, LinSrgb};
455 ///
456 /// let linear = LinSrgb::<f32>::from_encoding(Srgb::new(96u8, 127, 0));
457 /// ```
458 ///
459 /// See the transfer function types in the [`encoding`](crate::encoding)
460 /// module for details and performance characteristics.
461 pub fn from_encodingrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<Linear<S>, T>`]from_encoding().<U, St>(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<St, U>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<Linear<S>, T>`]
462 where
463 St: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = S>,
464 St::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<T, U>,
465 {
466 color.into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_linear().()
467 }
468 }
469
470 impl<S, T> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
471 where
472 S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#,
473 {
474 #[inline]
475 pub(craterust-analyzer cargo palette 0.7.6 crate/) fn reinterpret_asrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]reinterpret_as().<St>(self) -> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<St, T>
476 where
477 S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#<WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint# = <St::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#>,
478 St: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#,
479 {
480 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb# {
481 redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.: self.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.,
482 greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.: self.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.,
483 bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.: self.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.,
484 standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
485 }
486 }
487 }
488
489 /// <span id="Rgba"></span>[`Rgba`](crate::rgb::Rgba) implementations.
490 impl<S, T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>, A> {
491 /// Non-linear RGB.
492 pub const fn newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(red: T, green: T, blue: T, alpha: A) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`] {
493 Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# {
494 colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(red, green, blue),
495 alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.,
496 }
497 }
498
499 /// Convert the RGBA components into other number types.
500 ///
501 /// ```
502 /// use palette::Srgba;
503 ///
504 /// let rgba_u8: Srgba<u8> = Srgba::new(0.3, 0.7, 0.2, 0.5).into_format();
505 /// ```
506 ///
507 /// See also `into_linear` and `into_encoding` for a faster option if you
508 /// need to change between linear and non-linear encoding at the same time.
509 pub fn into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_format().<U, B>(self) -> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, U>, B>
510 where
511 U: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<T>,
512 B: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<A>,
513 {
514 Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# {
515 colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().(),
516 alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.: B::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.),
517 }
518 }
519
520 /// Convert the RGBA components from other number types.
521 ///
522 /// ```
523 /// use palette::Srgba;
524 ///
525 /// let rgba_u8 = Srgba::<u8>::from_format(Srgba::new(0.3, 0.7, 0.2, 0.5));
526 /// ```
527 ///
528 /// See also `from_linear` and `from_encoding` for a faster option if you
529 /// need to change between linear and non-linear encoding at the same time.
530 pub fn from_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]from_format().<U, B>(color: Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, U>, B>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]
531 where
532 T: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<U>,
533 A: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<B>,
534 {
535 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_format().()
536 }
537
538 /// Convert to a `(red, green, blue, alpha)` tuple.
539 pub fn into_componentsrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_components().(self) -> (T, T, T, A) {
540 (
541 self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.,
542 self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.,
543 self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.,
544 self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.,
545 )
546 }
547
548 /// Convert from a `(red, green, blue, alpha)` tuple.
549 pub fn from_componentsrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]from_components().((red, green, blue, alpha): (T, T, T, A)) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`] {
550 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(red, green, blue, alpha)
551 }
552 }
553
554 impl<S> Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8> {
555 /// Convert to a packed `u32` with with specifiable component order.
556 ///
557 /// ```
558 /// use palette::{rgb, Srgba};
559 ///
560 /// let integer = Srgba::new(96u8, 127, 0, 255).into_u32::<rgb::channels::Argb>();
561 /// assert_eq!(0xFF607F00, integer);
562 /// ```
563 ///
564 /// It's also possible to use `From` and `Into`, which defaults to the
565 /// `0xRRGGBBAA` component order:
566 ///
567 /// ```
568 /// use palette::Srgba;
569 ///
570 /// let integer = u32::from(Srgba::new(96u8, 127, 0, 255));
571 /// assert_eq!(0x607F00FF, integer);
572 /// ```
573 ///
574 /// See [Packed](crate::cast::Packed) for more details.
575 #[inline]
576 pub fn into_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`]into_u32().<O>(self) -> u32
577 where
578 O: ComponentOrderrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>, u32>,
579 {
580 O::packrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#pack().(self)
581 }
582
583 /// Convert from a packed `u32` with specifiable component order.
584 ///
585 /// ```
586 /// use palette::{rgb, Srgba};
587 ///
588 /// let rgba = Srgba::from_u32::<rgb::channels::Argb>(0xFF607F00);
589 /// assert_eq!(Srgba::new(96u8, 127, 0, 255), rgba);
590 /// ```
591 ///
592 /// It's also possible to use `From` and `Into`, which defaults to the
593 /// `0xRRGGBBAA` component order:
594 ///
595 /// ```
596 /// use palette::Srgba;
597 ///
598 /// let rgba = Srgba::from(0x607F00FF);
599 /// assert_eq!(Srgba::new(96u8, 127, 0, 255), rgba);
600 /// ```
601 ///
602 /// See [Packed](crate::cast::Packed) for more details.
603 #[inline]
604 pub fn from_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`]from_u32().<O>(color: u32) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`]
605 where
606 O: ComponentOrderrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>, u32>,
607 {
608 O::unpackrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#unpack().(color)
609 }
610 }
611
612 impl<S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#, T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>, A> {
613 /// Convert the color to linear RGB with transparency.
614 ///
615 /// Some transfer functions allow the component type to be converted at the
616 /// same time. This is usually offered with increased performance, compared
617 /// to using [`into_format`][Rgb::into_format].
618 ///
619 /// ```
620 /// use palette::{Srgba, LinSrgba};
621 ///
622 /// let linear: LinSrgba<f32> = Srgba::new(96u8, 127, 0, 38).into_linear();
623 /// ```
624 ///
625 /// See the transfer function types in the [`encoding`](crate::encoding)
626 /// module for details and performance characteristics.
627 pub fn into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_linear().<U, B>(self) -> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#>, U>, B>
628 where
629 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<U, T>,
630 B: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<A>,
631 {
632 Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# {
633 colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: self.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color..into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_linear().(),
634 alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.: B::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(self.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.),
635 }
636 }
637
638 /// Convert linear RGB to non-linear RGB with transparency.
639 ///
640 /// Some transfer functions allow the component type to be converted at the
641 /// same time. This is usually offered with increased performance, compared
642 /// to using [`into_format`][Rgb::into_format].
643 ///
644 /// ```
645 /// use palette::{Srgba, LinSrgba};
646 ///
647 /// let encoded = Srgba::<u8>::from_linear(LinSrgba::new(0.95f32, 0.90, 0.30, 0.75));
648 /// ```
649 ///
650 /// See the transfer function types in the [`encoding`](crate::encoding)
651 /// module for details and performance characteristics.
652 pub fn from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]from_linear().<U, B>(color: Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#>, U>, B>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]
653 where
654 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<U, T>,
655 A: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<B>,
656 {
657 Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha# {
658 colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]from_linear().(color.colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.),
659 alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.: A::from_stimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#from_stimulus().(color.alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#alpha.),
660 }
661 }
662 }
663
664 impl<S: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#, T, A> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<S>, T>, A> {
665 /// Convert a linear color to a different encoding with transparency.
666 ///
667 /// Some transfer functions allow the component type to be converted at the
668 /// same time. This is usually offered with increased performance, compared
669 /// to using [`into_format`][Rgb::into_format].
670 ///
671 /// ```
672 /// use palette::{Srgba, LinSrgba};
673 ///
674 /// let encoded: Srgba<u8> = LinSrgba::new(0.95f32, 0.90, 0.30, 0.75).into_encoding();
675 /// ```
676 ///
677 /// See the transfer function types in the [`encoding`](crate::encoding)
678 /// module for details and performance characteristics.
679 pub fn into_encodingrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<Linear<S>, T>, A>`]into_encoding().<U, B, St>(self) -> Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<St, U>, B>
680 where
681 St: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = S>,
682 St::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, U>,
683 B: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<A>,
684 {
685 Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#::<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<St, U>, B>::from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]from_linear().(self)
686 }
687
688 /// Convert RGB from a different encoding to linear with transparency.
689 ///
690 /// Some transfer functions allow the component type to be converted at the
691 /// same time. This is usually offered with increased performance, compared
692 /// to using [`into_format`][Rgb::into_format].
693 ///
694 /// ```
695 /// use palette::{Srgba, LinSrgba};
696 ///
697 /// let linear = LinSrgba::<f32>::from_encoding(Srgba::new(96u8, 127, 0, 38));
698 /// ```
699 ///
700 /// See the transfer function types in the [`encoding`](crate::encoding)
701 /// module for details and performance characteristics.
702 pub fn from_encodingrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<Linear<S>, T>, A>`]from_encoding().<U, B, St>(color: Alpharust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<St, U>, B>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<Linear<S>, T>, A>`]
703 where
704 St: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = S>,
705 St::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<T, U>,
706 A: FromStimulusrust-analyzer cargo palette 0.7.6 stimulus/FromStimulus#<B>,
707 {
708 color.into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_linear().()
709 }
710 }
711
712 impl_reference_component_methodsrust-analyzer cargo palette 0.7.6 macros/reference_component/impl_reference_component_methods!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.], standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
713 impl_struct_of_arrays_methodsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_arrays_methods!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [red, green, blue], standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
714
715 impl<S1, S2, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S2, T>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S1, T>
716 where
717 S1: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# + 'static,
718 S2: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# + 'static,
719 S1::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, T>,
720 S2::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<T, T>,
721 S2::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#<WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint# = <S1::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#>,
722 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<<S2::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S2, T>>,
723 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S1, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<<S1::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#, T>>,
724 {
725 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S1, T>`][`FromColorUnclamped<Rgb<S2, T>>`]from_color_unclamped().(rgb: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S2, T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S1, T>`][`FromColorUnclamped<Rgb<S2, T>>`] {
726 let rgb_space1 = TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<<S1::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::Primariesrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#Primaries#>();
727 let rgb_space2 = TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<<S2::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::Primariesrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#Primaries#>();
728
729 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<S1>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<S2>() {
730 rgb.reinterpret_asrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]reinterpret_as().()
731 } else if rgb_space1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().rgb_space2 {
732 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S1, T>`][`FromColorUnclamped<Rgb<S2, T>>`]::from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]from_linear().(rgb.into_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_linear().().reinterpret_asrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]reinterpret_as().())
733 } else {
734 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S1, T>`][`FromColorUnclamped<Rgb<S2, T>>`]::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(rgb))
735 }
736 }
737 }
738
739 impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#, T>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
740 where
741 S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#,
742 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, T>,
743 <S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::Primariesrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#Primaries#: Primariesrust-analyzer cargo palette 0.7.6 rgb/Primaries#<T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>,
744 <S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#: WhitePointrust-analyzer cargo palette 0.7.6 white_point/WhitePoint#<T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>,
745 T: Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + FromScalarrust-analyzer cargo palette 0.7.6 num/FromScalar#,
746 T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#: Realrust-analyzer cargo palette 0.7.6 num/Real#
747 + Reciprust-analyzer cargo palette 0.7.6 num/Recip#
748 + IsValidDivisorrust-analyzer cargo palette 0.7.6 num/IsValidDivisor#<Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask# = bool>
749 + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#
750 + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#
751 + FromScalarrust-analyzer cargo palette 0.7.6 num/FromScalar#<Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar# = T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>,
752 Yxyrust-analyzer cargo palette 0.7.6 yxy/Yxy#<Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>: IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<Anyrust-analyzer cargo palette 0.7.6 white_point/Any#, T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>>,
753 {
754 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Xyz<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>>`]from_color_unclamped().(color: Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#, T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Xyz<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>>`] {
755 let transform_matrix = S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#::xyz_to_rgb_matrixrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#xyz_to_rgb_matrix().().map_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or_else().(
756 || matrix_inverserust-analyzer cargo palette 0.7.6 matrix/matrix_inverse().(rgb_to_xyz_matrixrust-analyzer cargo palette 0.7.6 matrix/rgb_to_xyz_matrix().::<S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#, T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#>()),
757 |matrix| matrix_maprust-analyzer cargo palette 0.7.6 matrix/matrix_map().(matrix, T::Scalarrust-analyzer cargo palette 0.7.6 num/FromScalar#Scalar#::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().),
758 );
759 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Xyz<<<S as RgbStandard>::Space as RgbSpace>::WhitePoint, T>>`]::from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]from_linear().(multiply_xyz_to_rgbrust-analyzer cargo palette 0.7.6 matrix/multiply_xyz_to_rgb().(transform_matrix, color))
760 }
761 }
762
763 impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
764 where
765 T: Realrust-analyzer cargo palette 0.7.6 num/Real#
766 + RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#
767 + UnsignedAnglerust-analyzer cargo palette 0.7.6 angle/UnsignedAngle#
768 + Zerorust-analyzer cargo palette 0.7.6 num/Zero#
769 + Onerust-analyzer cargo palette 0.7.6 num/One#
770 + Absrust-analyzer cargo palette 0.7.6 num/Abs#
771 + Roundrust-analyzer cargo palette 0.7.6 num/Round#
772 + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#
773 + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#
774 + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
775 T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T> + BitOpsrust-analyzer cargo palette 0.7.6 bool_mask/BitOps# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
776 {
777 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Hsl<S, T>>`]from_color_unclamped().(hsl: Hslrust-analyzer cargo palette 0.7.6 hsl/Hsl#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Hsl<S, T>>`] {
778 let c = (T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().(hsl.lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::onerust-analyzer cargo palette 0.7.6 num/One#one().()).absrust-analyzer cargo palette 0.7.6 num/Abs#abs().())
779 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().hsl.saturationrust-analyzer cargo palette 0.7.6 hsl/Hsl#saturation.;
780 let h = hsl.huerust-analyzer cargo palette 0.7.6 hsl/Hsl#hue..into_positive_degreesrust-analyzer cargo palette 0.7.6 hues/impl#[`RgbHue<T>`]into_positive_degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(60.0);
781 // We avoid using %, since it's not always (or never?) supported in SIMD
782 let h_mod_two = h.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().Roundrust-analyzer cargo palette 0.7.6 num/Round#::floorrust-analyzer cargo palette 0.7.6 num/Round#floor().(h.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0);
783 let x = c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().(h_mod_two rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::onerust-analyzer cargo palette 0.7.6 num/One#one().()).absrust-analyzer cargo palette 0.7.6 num/Abs#abs().());
784 let m = hsl.lightnessrust-analyzer cargo palette 0.7.6 hsl/Hsl#lightness. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5);
785
786 let is_zone0 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::onerust-analyzer cargo palette 0.7.6 num/One#one().());
787 let is_zone1 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::onerust-analyzer cargo palette 0.7.6 num/One#one().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0));
788 let is_zone2 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0));
789 let is_zone3 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0));
790 let is_zone4 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(5.0));
791
792 let red = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
793 if is_zone1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). &is_zone4 => x.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
794 if is_zone2.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). &is_zone3 => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
795 else => c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
796 };
797
798 let green = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
799 if is_zone0.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). &is_zone3 => x.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
800 if is_zone1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). &is_zone2 => c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
801 else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
802 };
803
804 let blue = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
805 if is_zone0 |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). is_zone1 => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
806 if is_zone3 |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). is_zone4 => c,
807 else => x,
808 };
809
810 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb# {
811 redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.: red rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().m.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
812 greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.: green rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().m.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
813 bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.: blue rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().m,
814 standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
815 }
816 }
817 }
818
819 impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
820 where
821 T: Realrust-analyzer cargo palette 0.7.6 num/Real#
822 + RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle#
823 + UnsignedAnglerust-analyzer cargo palette 0.7.6 angle/UnsignedAngle#
824 + Roundrust-analyzer cargo palette 0.7.6 num/Round#
825 + Zerorust-analyzer cargo palette 0.7.6 num/Zero#
826 + Onerust-analyzer cargo palette 0.7.6 num/One#
827 + Absrust-analyzer cargo palette 0.7.6 num/Abs#
828 + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#
829 + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics#
830 + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
831 T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T> + BitOpsrust-analyzer cargo palette 0.7.6 bool_mask/BitOps# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
832 {
833 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Hsv<S, T>>`]from_color_unclamped().(hsv: Hsvrust-analyzer cargo palette 0.7.6 hsv/Hsv#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Hsv<S, T>>`] {
834 let c = hsv.valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().hsv.saturationrust-analyzer cargo palette 0.7.6 hsv/Hsv#saturation.;
835 let h = hsv.huerust-analyzer cargo palette 0.7.6 hsv/Hsv#hue..into_positive_degreesrust-analyzer cargo palette 0.7.6 hues/impl#[`RgbHue<T>`]into_positive_degrees().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#div().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(60.0);
836 // We avoid using %, since it's not always (or never?) supported in SIMD
837 let h_mod_two = h.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().Roundrust-analyzer cargo palette 0.7.6 num/Round#::floorrust-analyzer cargo palette 0.7.6 num/Round#floor().(h.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(0.5)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0);
838 let x = c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(T::onerust-analyzer cargo palette 0.7.6 num/One#one().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().(h_mod_two rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().T::onerust-analyzer cargo palette 0.7.6 num/One#one().()).absrust-analyzer cargo palette 0.7.6 num/Abs#abs().());
839 let m = hsv.valuerust-analyzer cargo palette 0.7.6 hsv/Hsv#value. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().();
840
841 let is_zone0 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::onerust-analyzer cargo palette 0.7.6 num/One#one().());
842 let is_zone1 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::onerust-analyzer cargo palette 0.7.6 num/One#one().()) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0));
843 let is_zone2 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0));
844 let is_zone3 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(3.0)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0));
845 let is_zone4 = h.gt_eqrust-analyzer cargo palette 0.7.6 num/PartialCmp#gt_eq().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(4.0)) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitAnd#bitand().h.ltrust-analyzer cargo palette 0.7.6 num/PartialCmp#lt().(&T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(5.0));
846
847 let red = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
848 if is_zone1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). &is_zone4 => x.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
849 if is_zone2.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). &is_zone3 => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
850 else => c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
851 };
852
853 let green = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
854 if is_zone0.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). &is_zone3 => x.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
855 if is_zone1.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). &is_zone2 => c.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
856 else => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
857 };
858
859 let blue = lazy_selectrust-analyzer cargo palette 0.7.6 macros/lazy_select/lazy_select!! {
860 if is_zone0 |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). is_zone1 => T::zerorust-analyzer cargo palette 0.7.6 num/Zero#zero().(),
861 if is_zone3 |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/BitOr#bitor(). is_zone4 => c,
862 else => x,
863 };
864
865 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb# {
866 redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.: red rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().m.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
867 greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.: green rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().m.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
868 bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.: blue rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#add().m,
869 standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
870 }
871 }
872 }
873
874 impl<S, St, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#<St, T>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
875 where
876 S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard# + 'static,
877 St: LumaStandardrust-analyzer cargo palette 0.7.6 luma/LumaStandard#<WhitePointrust-analyzer cargo palette 0.7.6 luma/LumaStandard#WhitePoint# = <S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#> + 'static,
878 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, T>,
879 St::TransferFnrust-analyzer cargo palette 0.7.6 luma/LumaStandard#TransferFn#: IntoLinearrust-analyzer cargo palette 0.7.6 encoding/IntoLinear#<T, T>,
880 T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
881 {
882 #[inline]
883 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Luma<St, T>>`]from_color_unclamped().(color: Lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#<St, T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Luma<St, T>>`] {
884 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<St::TransferFnrust-analyzer cargo palette 0.7.6 luma/LumaStandard#TransferFn#>() {
885 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb# {
886 redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.: color.lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#luma..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
887 greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.: color.lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#luma..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
888 bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.: color.lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#luma.,
889 standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
890 }
891 } else {
892 let luma = color.into_linearrust-analyzer cargo palette 0.7.6 luma/luma/impl#[`Luma<S, T>`]into_linear().();
893
894 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Luma<St, T>>`]::from_linearrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]from_linear().(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb# {
895 redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.: luma.lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#luma..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
896 greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.: luma.lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#luma..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
897 bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.: luma.lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#luma.,
898 standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#,
899 })
900 }
901 }
902 }
903
904 impl<S, T> FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
905 where
906 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#,
907 S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#,
908 S::TransferFnrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#TransferFn#: FromLinearrust-analyzer cargo palette 0.7.6 encoding/FromLinear#<T, T>,
909 S::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#: RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#<WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint# = D65rust-analyzer cargo palette 0.7.6 white_point/D65#> + 'static,
910 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>, T>: IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Oklab<T>>`]>,
911 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#, T>: FromColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#<Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>> + IntoColorUnclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#<Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Oklab<T>>`]>,
912 {
913 fn from_color_unclampedrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Oklab<T>>`]from_color_unclamped().(oklab: Oklabrust-analyzer cargo palette 0.7.6 oklab/Oklab#<T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`FromColorUnclamped<Oklab<T>>`] {
914 if TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<<S as RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#>::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space#>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId][`PartialEq<Self>`]eq().TypeIdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/TypeId#::ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/impl#[TypeId]of().::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>() {
915 // Use direct sRGB to Oklab conversion
916 // Rounding errors are likely a contributing factor to differences.
917 // Also the conversion via XYZ doesn't use pre-defined matrices (yet)
918 oklab_to_linear_srgbrust-analyzer cargo palette 0.7.6 oklab/oklab_to_linear_srgb().(oklab).into_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#into_color_unclamped().()
919 } else {
920 // Convert via XYZ
921 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/FromColorUnclamped#from_color_unclamped().(oklab).into_color_unclampedrust-analyzer cargo palette 0.7.6 convert/from_into_color_unclamped/IntoColorUnclamped#into_color_unclamped().()
922 }
923 }
924 }
925
926 impl_is_within_boundsrust-analyzer cargo palette 0.7.6 macros/clamp/impl_is_within_bounds!! {
927 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S> {
928 redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red. => [Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][IsWithinBounds]::min_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_red().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][IsWithinBounds]::max_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_red().()],
929 greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green. => [Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][IsWithinBounds]::min_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_green().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][IsWithinBounds]::max_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_green().()],
930 bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue. => [Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][IsWithinBounds]::min_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_blue().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][IsWithinBounds]::max_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_blue().()]
931 }
932 where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#
933 }
934 impl_clamprust-analyzer cargo palette 0.7.6 macros/clamp/impl_clamp!! {
935 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S> {
936 redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red. => [Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][ClampAssign]::min_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_red().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][ClampAssign]::max_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_red().()],
937 greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green. => [Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][ClampAssign]::min_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_green().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][ClampAssign]::max_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_green().()],
938 bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue. => [Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][ClampAssign]::min_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_blue().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][ClampAssign]::max_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_blue().()]
939 }
940 other {standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.}
941 where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#
942 }
943
944 impl_mixrust-analyzer cargo palette 0.7.6 macros/mix/impl_mix!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>);
945 impl_lightenrust-analyzer cargo palette 0.7.6 macros/lighten_saturate/impl_lighten!! {
946 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>
947 increase {
948 red => [Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Lighten]::min_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_red().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Lighten]::max_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_red().()],
949 green => [Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Lighten]::min_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_green().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Lighten]::max_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_green().()],
950 blue => [Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Lighten]::min_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_blue().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Lighten]::max_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_blue().()]
951 }
952 other {}
953 phantom: standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.
954 where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#,
955 }
956
957 impl<S, T> GetHuerust-analyzer cargo palette 0.7.6 GetHue# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
958 where
959 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + RealAnglerust-analyzer cargo palette 0.7.6 angle/RealAngle# + Trigonometryrust-analyzer cargo palette 0.7.6 num/Trigonometry# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#,
960 {
961 type Huerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][GetHue]Hue# = RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T>;
962
963 fn get_huerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][GetHue]get_hue().(&self) -> RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#<T> {
964 let sqrt_3: T = T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(1.73205081);
965
966 RgbHuerust-analyzer cargo palette 0.7.6 hues/RgbHue#::from_cartesianrust-analyzer cargo palette 0.7.6 hues/impl#[`RgbHue<T>`]from_cartesian().(
967 self.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().T::from_f64rust-analyzer cargo palette 0.7.6 num/Real#from_f64().(2.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().self.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().self.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().(),
968 sqrt_3 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Mul#mul().(self.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Sub#sub().self.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()),
969 )
970 }
971 }
972
973 impl_premultiplyrust-analyzer cargo palette 0.7.6 macros/blend/impl_premultiply!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S> {redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.} phantom: standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
974 impl_euclidean_distancerust-analyzer cargo palette 0.7.6 macros/color_difference/impl_euclidean_distance!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S> {redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.});
975
976 impl<S, T> StimulusColorrust-analyzer cargo palette 0.7.6 stimulus/StimulusColor# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T> where T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus# {}
977
978 impl<S, T> HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
979 where
980 T: HasBoolMaskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#,
981 {
982 type Maskrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][HasBoolMask]Mask# = T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#;
983 }
984
985 impl<S, T> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
986 where
987 T: Stimulusrust-analyzer cargo palette 0.7.6 stimulus/Stimulus#,
988 {
989 fn defaultrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Default]default().() -> Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T> {
990 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Default]::min_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_red().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Default]::min_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_green().(), Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Default]::min_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_blue().())
991 }
992 }
993
994 impl_color_addrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_add!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.], standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
995 impl_color_subrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_sub!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.], standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
996 impl_color_mulrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_mul!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.], standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
997 impl_color_divrust-analyzer cargo palette 0.7.6 macros/arithmetics/impl_color_div!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.], standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
998
999 impl_tuple_conversionrust-analyzer cargo palette 0.7.6 macros/convert/impl_tuple_conversion!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S> as (T, T, T));
1000 impl_array_castsrust-analyzer cargo palette 0.7.6 macros/casting/impl_array_casts!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>, [T; 3]);
1001 impl_simd_array_conversionrust-analyzer cargo palette 0.7.6 macros/simd/impl_simd_array_conversion!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [red, green, blue], standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
1002 impl_struct_of_array_traitsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/impl_struct_of_array_traits!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.], standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
1003
1004 impl_eqrust-analyzer cargo palette 0.7.6 macros/equality/impl_eq!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.]);
1005 impl_copy_clonerust-analyzer cargo palette 0.7.6 macros/copy_clone/impl_copy_clone!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S>, [redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.], standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.);
1006
1007 impl<S, T> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::LowerHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/LowerHex# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
1008 where
1009 T: fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::LowerHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/LowerHex#,
1010 {
1011 fn fmtrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][LowerHex]fmt().(&self, f: &mut 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#) -> 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# {
1012 let size = f.widthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]width().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(::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().::<T>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2);
1013 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
1014 f,
1015 "{:0width$x}{:0width$x}{:0width$x}",
1016 self.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.,
1017 self.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.,
1018 self.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.,
1019 width = size
1020 )
1021 }
1022 }
1023
1024 impl<S, T> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::UpperHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/UpperHex# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
1025 where
1026 T: fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::UpperHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/UpperHex#,
1027 {
1028 fn fmtrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][UpperHex]fmt().(&self, f: &mut 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#) -> 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# {
1029 let size = f.widthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]width().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(::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().::<T>() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2);
1030 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
1031 f,
1032 "{:0width$X}{:0width$X}{:0width$X}",
1033 self.redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red.,
1034 self.greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green.,
1035 self.bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.,
1036 width = size
1037 )
1038 }
1039 }
1040
1041 /// Error type for parsing a string of hexadecimal characters to an `Rgb` color.
1042 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
1043 pub enum FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError# {
1044 /// An error occurred while parsing the string into a valid integer.
1045 ParseIntErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#ParseIntError#(ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#),
1046 /// The hex value was not in a valid 3 or 6 character format.
1047 HexFormatErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#HexFormatError#(&'static str),
1048 /// The hex value was not in a valid 4 or 8 character format.
1049 RgbaHexFormatErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#RgbaHexFormatError#(&'static str),
1050 }
1051
1052 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#> for FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError# {
1053 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[FromHexError][`From<ParseIntError>`]from().(err: ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#) -> FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError# {
1054 FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::ParseIntErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#ParseIntError#(err)
1055 }
1056 }
1057
1058 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'static str> for FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError# {
1059 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[FromHexError][`From<&'static str>`]from().(err: &'static str) -> FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError# {
1060 FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::HexFormatErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#HexFormatError#(err)
1061 }
1062 }
1063
1064 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 FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError# {
1065 fn fmtrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[FromHexError][Display]fmt().(&self, f: &mut 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#<'_>) -> 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# {
1066 match self {
1067 FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::ParseIntErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#ParseIntError#(e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", e),
1068 FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::HexFormatErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#HexFormatError#(s) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
1069 f,
1070 "{}, please use format '#fff', 'fff', '#ffffff' or 'ffffff'.",
1071 s
1072 ),
1073 FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::RgbaHexFormatErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#RgbaHexFormatError#(s) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(
1074 f,
1075 "{}, please use format '#ffff', 'ffff', '#ffffffff' or 'ffffffff'.",
1076 s
1077 ),
1078 }
1079 }
1080 }
1081
1082 #[cfg(feature = "std")]
1083 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError# {
1084 fn sourcerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[FromHexError][Error]source().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&(dyn stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static)> {
1085 match self {
1086 FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::HexFormatErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#HexFormatError#(_s) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
1087 FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::RgbaHexFormatErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#RgbaHexFormatError#(_s) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
1088 FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::ParseIntErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#ParseIntError#(e) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(e),
1089 }
1090 }
1091 }
1092
1093 impl<S> FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8> {
1094 type Errrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]Err# = FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#;
1095
1096 /// Parses a color hex code of format '#ff00bb' or '#abc' (with or without the leading '#') into a
1097 /// [`Rgb<S, u8>`] instance.
1098 fn from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().(hex: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr], Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
1099 let hex_code = hex.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('#').map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(hex, |stripped| stripped);
1100 match hex_code.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() {
1101 3 => {
1102 let red = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1103 let green = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1104 let blue = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1105 let col: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8> = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(red rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().17, green rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().17, blue rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().17);
1106 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(col)
1107 }
1108 6 => {
1109 let red = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1110 let green = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1111 let blue = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1112 let col: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8> = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(red, green, blue);
1113 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(col)
1114 }
1115 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::HexFormatErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#HexFormatError#("invalid hex code format")),
1116 }
1117 }
1118 }
1119
1120 impl<S> FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8> {
1121 type Errrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]Err# = FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#;
1122
1123 /// Parses a color hex code of format '#ff00bbff' or '#abcd' (with or without the leading '#') into a
1124 /// [`Rgba<S, u8>`] instance.
1125 fn from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().(hex: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr], Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]::Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#Err#> {
1126 let hex_code = hex.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('#').map_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map_or().(hex, |stripped| stripped);
1127 match hex_code.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() {
1128 4 => {
1129 let red = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1130 let green = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1131 let blue = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1132 let alpha = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1133 let col: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8> = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(red rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().17, green rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().17, blue rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().17, alpha rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Mul<Self>`]mul().17);
1134 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(col)
1135 }
1136 8 => {
1137 let red = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1138 let green = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1139 let blue = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#6]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1140 let alpha = u8::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]from_str_radix().(&hex_code[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().6..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#8]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., 16)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1141 let col: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8> = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(red, green, blue, alpha);
1142 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(col)
1143 }
1144 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(FromHexErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#::RgbaHexFormatErrorrust-analyzer cargo palette 0.7.6 rgb/rgb/FromHexError#RgbaHexFormatError#("invalid hex code format")),
1145 }
1146 }
1147 }
1148
1149 impl<S, T, P, O> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>> for Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<O, P>
1150 where
1151 O: ComponentOrderrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, T>, P>,
1152 Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, T>: Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>>,
1153 {
1154 #[inline]
1155 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Packed<O, P>`][`From<Rgb<S, T>>`]from().(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Packed<O, P>`][`From<Rgb<S, T>>`] {
1156 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Packed<O, P>`][`From<Rgb<S, T>>`]::fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Packed<O, P>`][`From<Alpha<Rgb<S, T>, T>>`]from().(Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#from().(color))
1157 }
1158 }
1159
1160 impl<S, T, O, P> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, T>> for Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<O, P>
1161 where
1162 O: ComponentOrderrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, T>, P>,
1163 {
1164 #[inline]
1165 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Packed<O, P>`][`From<Alpha<Rgb<S, T>, T>>`]from().(color: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, T>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Packed<O, P>`][`From<Alpha<Rgb<S, T>, T>>`] {
1166 Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#::packrust-analyzer cargo palette 0.7.6 cast/packed/impl#[`Packed<O, P>`]pack().(color)
1167 }
1168 }
1169
1170 impl<S, O, P> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<O, P>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8>
1171 where
1172 O: ComponentOrderrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>, P>,
1173 {
1174 #[inline]
1175 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<Packed<O, P>>`]from().(packed: Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<O, P>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<Packed<O, P>>`] {
1176 Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, T>`][`From<Packed<O, P>>`]from().(packed).colorrust-analyzer cargo palette 0.7.6 alpha/alpha/Alpha#color.
1177 }
1178 }
1179
1180 impl<S, T, O, P> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<O, P>> for Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, T>
1181 where
1182 O: ComponentOrderrust-analyzer cargo palette 0.7.6 cast/packed/ComponentOrder#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, T>, P>,
1183 {
1184 #[inline]
1185 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, T>`][`From<Packed<O, P>>`]from().(packed: Packedrust-analyzer cargo palette 0.7.6 cast/packed/Packed#<O, P>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, T>`][`From<Packed<O, P>>`] {
1186 packed.unpackrust-analyzer cargo palette 0.7.6 cast/packed/impl#[`Packed<O, P>`]unpack().()
1187 }
1188 }
1189
1190 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<u32> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8> {
1191 #[inline]
1192 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<u32>`]from().(color: u32) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<u32>`] {
1193 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<u32>`]::from_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`]from_u32().::<superrust-analyzer cargo palette 0.7.6 rgb/::channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Argbrust-analyzer cargo palette 0.7.6 rgb/channels/Argb#>(color)
1194 }
1195 }
1196
1197 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<u32> for Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8> {
1198 #[inline]
1199 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][`From<u32>`]from().(color: u32) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][`From<u32>`] {
1200 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][`From<u32>`]::from_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`]from_u32().::<superrust-analyzer cargo palette 0.7.6 rgb/::channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Rgbarust-analyzer cargo palette 0.7.6 rgb/channels/Rgba#>(color)
1201 }
1202 }
1203
1204 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8>> for u32 {
1205 #[inline]
1206 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[u32][`From<Rgb<S, u8>>`]from().(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[u32][`From<Rgb<S, u8>>`] {
1207 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::into_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`]into_u32().::<superrust-analyzer cargo palette 0.7.6 rgb/::channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Argbrust-analyzer cargo palette 0.7.6 rgb/channels/Argb#>(color)
1208 }
1209 }
1210
1211 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>> for u32 {
1212 #[inline]
1213 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[u32][`From<Alpha<Rgb<S, u8>, u8>>`]from().(color: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[u32][`From<Alpha<Rgb<S, u8>, u8>>`] {
1214 Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::into_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`]into_u32().::<superrust-analyzer cargo palette 0.7.6 rgb/::channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Rgbarust-analyzer cargo palette 0.7.6 rgb/channels/Rgba#>(color)
1215 }
1216 }
1217
1218 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f32> {
1219 #[inline]
1220 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S>`][`From<Rgb<S, u8>>`]from().(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S>`][`From<Rgb<S, u8>>`] {
1221 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().()
1222 }
1223 }
1224
1225 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>> for Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f32> {
1226 #[inline]
1227 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S>, f32>`][`From<Alpha<Rgb<S, u8>, u8>>`]from().(color: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S>, f32>`][`From<Alpha<Rgb<S, u8>, u8>>`] {
1228 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_format().()
1229 }
1230 }
1231
1232 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f32>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8> {
1233 #[inline]
1234 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<Rgb<S>>`]from().(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f32>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<Rgb<S>>`] {
1235 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().()
1236 }
1237 }
1238
1239 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f32>> for Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8> {
1240 #[inline]
1241 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][`From<Alpha<Rgb<S>, f32>>`]from().(color: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f32>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][`From<Alpha<Rgb<S>, f32>>`] {
1242 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_format().()
1243 }
1244 }
1245
1246 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f64> {
1247 #[inline]
1248 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, f64>`][`From<Rgb<S, u8>>`]from().(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, f64>`][`From<Rgb<S, u8>>`] {
1249 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().()
1250 }
1251 }
1252
1253 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>> for Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f64> {
1254 #[inline]
1255 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, f64>, f64>`][`From<Alpha<Rgb<S, u8>, u8>>`]from().(color: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, f64>, f64>`][`From<Alpha<Rgb<S, u8>, u8>>`] {
1256 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_format().()
1257 }
1258 }
1259
1260 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f64>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, u8> {
1261 #[inline]
1262 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<Rgb<S, f64>>`]from().(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f64>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<Rgb<S, f64>>`] {
1263 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().()
1264 }
1265 }
1266
1267 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f64>> for Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, u8> {
1268 #[inline]
1269 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][`From<Alpha<Rgb<S, f64>, f64>>`]from().(color: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f64>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][`From<Alpha<Rgb<S, f64>, f64>>`] {
1270 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_format().()
1271 }
1272 }
1273
1274 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f32>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f64> {
1275 #[inline]
1276 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, f64>`][`From<Rgb<S>>`]from().(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f32>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, f64>`][`From<Rgb<S>>`] {
1277 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().()
1278 }
1279 }
1280
1281 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f32>> for Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f64> {
1282 #[inline]
1283 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, f64>, f64>`][`From<Alpha<Rgb<S>, f32>>`]from().(color: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f32>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, f64>, f64>`][`From<Alpha<Rgb<S>, f32>>`] {
1284 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_format().()
1285 }
1286 }
1287
1288 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f64>> for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f32> {
1289 #[inline]
1290 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S>`][`From<Rgb<S, f64>>`]from().(color: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, f64>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S>`][`From<Rgb<S, f64>>`] {
1291 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]into_format().()
1292 }
1293 }
1294
1295 impl<S> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f64>> for Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f32> {
1296 #[inline]
1297 fn fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S>, f32>`][`From<Alpha<Rgb<S, f64>, f64>>`]from().(color: Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#<S, f64>) -> Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S>, f32>`][`From<Alpha<Rgb<S, f64>, f64>>`] {
1298 color.into_formatrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]into_format().()
1299 }
1300 }
1301
1302 #[allow(deprecated)]
1303 impl<S, T> craterust-analyzer cargo palette 0.7.6 crate/::RelativeContrastrust-analyzer cargo palette 0.7.6 relative_contrast/RelativeContrast# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
1304 where
1305 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Arithmeticsrust-analyzer cargo palette 0.7.6 num/Arithmetics# + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp#,
1306 T::Maskrust-analyzer cargo palette 0.7.6 bool_mask/HasBoolMask#Mask#: LazySelectrust-analyzer cargo palette 0.7.6 bool_mask/LazySelect#<T>,
1307 S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#,
1308 Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#<<<S as RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#>::Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# as RgbSpacerust-analyzer cargo palette 0.7.6 rgb/RgbSpace#>::WhitePointrust-analyzer cargo palette 0.7.6 rgb/RgbSpace#WhitePoint#, T>: FromColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#<Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][RelativeContrast]>,
1309 {
1310 type Scalarrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][RelativeContrast]Scalar# = T;
1311
1312 #[inline]
1313 fn get_contrast_ratiorust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][RelativeContrast]get_contrast_ratio().(self, other: Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][RelativeContrast]) -> T {
1314 let xyz1 = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#from_color().(self);
1315 let xyz2 = Xyzrust-analyzer cargo palette 0.7.6 xyz/Xyz#::from_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/FromColor#from_color().(other);
1316
1317 craterust-analyzer cargo palette 0.7.6 crate/::contrast_ratiorust-analyzer cargo palette 0.7.6 relative_contrast/contrast_ratio().(xyz1.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y., xyz2.yrust-analyzer cargo palette 0.7.6 xyz/Xyz#y.)
1318 }
1319 }
1320
1321 impl<S, T> Wcag21RelativeContrastrust-analyzer cargo palette 0.7.6 color_difference/Wcag21RelativeContrast# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T>
1322 where
1323 Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Wcag21RelativeContrast]: IntoColorrust-analyzer cargo palette 0.7.6 convert/from_into_color/IntoColor#<Lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>, T>>,
1324 S: RgbStandardrust-analyzer cargo palette 0.7.6 rgb/RgbStandard#<Spacerust-analyzer cargo palette 0.7.6 rgb/RgbStandard#Space# = craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>,
1325 T: Realrust-analyzer cargo palette 0.7.6 num/Real# + Addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#<T, Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Add#Output# = T> + Divrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#<T, Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/Div#Output# = T> + PartialCmprust-analyzer cargo palette 0.7.6 num/PartialCmp# + MinMaxrust-analyzer cargo palette 0.7.6 num/MinMax#,
1326 {
1327 type Scalarrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Wcag21RelativeContrast]Scalar# = T;
1328
1329 fn relative_luminancerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Wcag21RelativeContrast]relative_luminance().(self) -> Lumarust-analyzer cargo palette 0.7.6 luma/luma/Luma#<Linearrust-analyzer cargo palette 0.7.6 encoding/linear/Linear#<D65rust-analyzer cargo palette 0.7.6 white_point/D65#>, Selfrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][Wcag21RelativeContrast]::Scalarrust-analyzer cargo palette 0.7.6 color_difference/Wcag21RelativeContrast#Scalar#> {
1330 self.into_colorrust-analyzer cargo palette 0.7.6 convert/from_into_color/IntoColor#into_color().()
1331 }
1332 }
1333
1334 impl_rand_traits_cartesianrust-analyzer cargo palette 0.7.6 macros/random/impl_rand_traits_cartesian!!(UniformRgbrust-analyzer cargo palette 0.7.6 rgb/rgb/UniformRgb#, Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S> {redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.} phantom: standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.: PhantomData<S>);
1335
1336 #[cfg(feature = "bytemuck")]
1337 unsafe impl<S, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Zeroablerust-analyzer cargo bytemuck 1.25.2 zeroable/Zeroable# {}
1338
1339 #[cfg(feature = "bytemuck")]
1340 unsafe impl<S: 'static, T> bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# for Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<S, T> where T: bytemuckrust-analyzer cargo bytemuck 1.25.2 crate/::Podrust-analyzer cargo bytemuck 1.25.2 pod/Pod# {}
1341
1342 #[cfg(test)]
1343 mod testrust-analyzer cargo palette 0.7.6 rgb/rgb/test/ {
1344 use 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/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
1345
1346 use craterust-analyzer cargo palette 0.7.6 crate/::encodingrust-analyzer cargo palette 0.7.6 encoding/::Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#;
1347 use craterust-analyzer cargo palette 0.7.6 crate/::rgbrust-analyzer cargo palette 0.7.6 rgb/::channelsrust-analyzer cargo palette 0.7.6 rgb/channels/;
1348
1349 use superrust-analyzer cargo palette 0.7.6 rgb/rgb/::{Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#, Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#};
1350
1351 test_convert_into_from_xyzrust-analyzer cargo palette 0.7.6 macros/convert/test_convert_into_from_xyz!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#);
1352
1353 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1354 fn rangesrust-analyzer cargo palette 0.7.6 rgb/rgb/test/ranges().() {
1355 assert_rangesrust-analyzer cargo palette 0.7.6 macros/clamp/assert_ranges!! {
1356 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, f64>;
1357 clamped {
1358 red: 0.0 => 1.0,
1359 green: 0.0 => 1.0,
1360 blue: 0.0 => 1.0
1361 }
1362 clamped_min {}
1363 unclamped {}
1364 }
1365 }
1366
1367 raw_pixel_conversion_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_tests!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>: red, green, blue);
1368 raw_pixel_conversion_fail_testsrust-analyzer cargo palette 0.7.6 macros/casting/raw_pixel_conversion_fail_tests!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>: red, green, blue);
1369
1370 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1371 fn lower_hexrust-analyzer cargo palette 0.7.6 rgb/rgb/test/lower_hex().() {
1372 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1373 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:x}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(171, 193, 35)),
1374 "abc123"
1375 );
1376 }
1377
1378 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1379 fn lower_hex_small_numbersrust-analyzer cargo palette 0.7.6 rgb/rgb/test/lower_hex_small_numbers().() {
1380 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:x}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)), "010203");
1381 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1382 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:x}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u16>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1383 "000100020003"
1384 );
1385 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1386 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:x}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u32>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1387 "000000010000000200000003"
1388 );
1389 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1390 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:x}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u64>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1391 "000000000000000100000000000000020000000000000003"
1392 );
1393 }
1394
1395 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1396 fn lower_hex_custom_widthrust-analyzer cargo palette 0.7.6 rgb/rgb/test/lower_hex_custom_width().() {
1397 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1398 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:03x}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1399 "001002003"
1400 );
1401 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1402 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:03x}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u16>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1403 "001002003"
1404 );
1405 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1406 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:03x}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u32>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1407 "001002003"
1408 );
1409 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1410 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:03x}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u64>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1411 "001002003"
1412 );
1413 }
1414
1415 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1416 fn upper_hexrust-analyzer cargo palette 0.7.6 rgb/rgb/test/upper_hex().() {
1417 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1418 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:X}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(171, 193, 35)),
1419 "ABC123"
1420 );
1421 }
1422
1423 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1424 fn upper_hex_small_numbersrust-analyzer cargo palette 0.7.6 rgb/rgb/test/upper_hex_small_numbers().() {
1425 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:X}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)), "010203");
1426 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1427 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:X}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u16>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1428 "000100020003"
1429 );
1430 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1431 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:X}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u32>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1432 "000000010000000200000003"
1433 );
1434 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1435 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:X}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u64>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1436 "000000000000000100000000000000020000000000000003"
1437 );
1438 }
1439
1440 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1441 fn upper_hex_custom_widthrust-analyzer cargo palette 0.7.6 rgb/rgb/test/upper_hex_custom_width().() {
1442 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1443 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:03X}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1444 "001002003"
1445 );
1446 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1447 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:03X}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u16>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1448 "001002003"
1449 );
1450 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1451 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:03X}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u32>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1452 "001002003"
1453 );
1454 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1455 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:03X}", Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u64>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(1, 2, 3)),
1456 "001002003"
1457 );
1458 }
1459
1460 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1461 fn rgb_hex_into_fromrust-analyzer cargo palette 0.7.6 rgb/rgb/test/rgb_hex_into_from().() {
1462 let c1 = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`]from_u32().::<channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Argbrust-analyzer cargo palette 0.7.6 rgb/channels/Argb#>(0x1100_7FFF);
1463 let c2 = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0u8, 127, 255);
1464 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c1, c2);
1465 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::into_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`]into_u32().::<channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Argbrust-analyzer cargo palette 0.7.6 rgb/channels/Argb#>(c1), 0xFF00_7FFF);
1466
1467 let c1 = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`]from_u32().::<channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Rgbarust-analyzer cargo palette 0.7.6 rgb/channels/Rgba#>(0x007F_FF80);
1468 let c2 = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(0u8, 127, 255, 128);
1469 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c1, c2);
1470 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1471 Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::into_u32rust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`]into_u32().::<channelsrust-analyzer cargo palette 0.7.6 rgb/channels/::Rgbarust-analyzer cargo palette 0.7.6 rgb/channels/Rgba#>(c1),
1472 0x007F_FF80
1473 );
1474
1475 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1476 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][`From<u32>`]from().(0x7FFF_FF80),
1477 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`][`From<(T, T, T)>`]from().((255u8, 255, 128))
1478 );
1479 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1480 Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][`From<u32>`]from().(0x7FFF_FF80),
1481 Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::fromrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`][`From<(T, T, T, A)>`]from().((127u8, 255, 255, 128))
1482 );
1483 }
1484
1485 #[cfg(feature = "serializing")]
1486 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1487 fn serializerust-analyzer cargo palette 0.7.6 rgb/rgb/test/serialize().() {
1488 let serialized = ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::to_stringrust-analyzer cargo serde_json 1.0.116 ser/to_string().(&Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.3, 0.8, 0.1)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1489
1490 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, r#"{"red":0.3,"green":0.8,"blue":0.1}"#);
1491 }
1492
1493 #[cfg(feature = "serializing")]
1494 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1495 fn deserializerust-analyzer cargo palette 0.7.6 rgb/rgb/test/deserialize().() {
1496 let deserialized: Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#> =
1497 ::serde_jsonrust-analyzer cargo serde_json 1.0.116 crate/::from_strrust-analyzer cargo serde_json 1.0.116 de/from_str().(r#"{"red":0.3,"green":0.8,"blue":0.1}"#).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
1498
1499 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(deserialized, Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0.3, 0.8, 0.1));
1500 }
1501
1502 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1503 fn from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/test/from_str().() {
1504 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#ffffff");
1505 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
1506 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(255, 255, 255));
1507 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#gggggg");
1508 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
1509 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#fff");
1510 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
1511 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(255, 255, 255));
1512 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#000000");
1513 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
1514 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0, 0, 0));
1515 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("");
1516 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
1517 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#123456");
1518 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().());
1519 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(18, 52, 86));
1520 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#iii");
1521 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
1522 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1523 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", c.errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()),
1524 "invalid digit found in string"
1525 );
1526 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#08f");
1527 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0, 136, 255));
1528 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("08f");
1529 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(0, 136, 255));
1530 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("ffffff");
1531 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(255, 255, 255));
1532 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("#12");
1533 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
1534 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1535 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", c.errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()),
1536 "invalid hex code format, \
1537 please use format \'#fff\', \'fff\', \'#ffffff\' or \'ffffff\'."
1538 );
1539 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("da0bce");
1540 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(218, 11, 206));
1541 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("f034e6");
1542 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(240, 52, 230));
1543 let c = Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, u8>`][FromStr]from_str().("abc");
1544 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]new().(170, 187, 204));
1545 let c = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().("#08ff");
1546 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(0, 136, 255, 255));
1547 let c = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().("08f0");
1548 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(0, 136, 255, 0));
1549 let c = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().("#da0bce80");
1550 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(218, 11, 206, 128));
1551 let c = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().("f034e680");
1552 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(240, 52, 230, 128));
1553 let c = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().("#ffffffff");
1554 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(255, 255, 255, 255));
1555 let c = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().("#ffff");
1556 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(c.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(255, 255, 255, 255));
1557 let c = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().("#gggggggg");
1558 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(c.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
1559 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1560 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", c.errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()),
1561 "invalid digit found in string"
1562 );
1563 let c = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().("#fff");
1564 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1565 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", c.errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()),
1566 "invalid hex code format, \
1567 please use format '#ffff', 'ffff', '#ffffffff' or 'ffffffff'."
1568 );
1569 let c = Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, u8>::from_strrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, u8>, u8>`][FromStr]from_str().("#ffffff");
1570 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
1571 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", c.errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]err().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()),
1572 "invalid hex code format, \
1573 please use format '#ffff', 'ffff', '#ffffffff' or 'ffffffff'."
1574 );
1575 }
1576
1577 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
1578 fn check_min_max_componentsrust-analyzer cargo palette 0.7.6 rgb/rgb/test/check_min_max_components().() {
1579 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, f32>::min_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_red().(), 0.0);
1580 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, f32>::min_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_green().(), 0.0);
1581 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, f32>::min_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]min_blue().(), 0.0);
1582 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, f32>::max_redrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_red().(), 1.0);
1583 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, f32>::max_greenrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_green().(), 1.0);
1584 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#::<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#, f32>::max_bluerust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Rgb<S, T>`]max_blue().(), 1.0);
1585 }
1586
1587 struct_of_arrays_testsrust-analyzer cargo palette 0.7.6 macros/struct_of_arrays/struct_of_arrays_tests!!(
1588 Rgbrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#<Srgbrust-analyzer cargo palette 0.7.6 encoding/srgb/Srgb#>[redrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#red., greenrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#green., bluerust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#blue.] phantom: standardrust-analyzer cargo palette 0.7.6 rgb/rgb/Rgb#standard.,
1589 Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(0.1f32, 0.2, 0.3, 0.4),
1590 Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(0.2, 0.3, 0.4, 0.5),
1591 Rgbarust-analyzer cargo palette 0.7.6 rgb/rgb/Rgba#::newrust-analyzer cargo palette 0.7.6 rgb/rgb/impl#[`Alpha<Rgb<S, T>, A>`]new().(0.3, 0.4, 0.5, 0.6)
1592 );
1593
1594 test_uniform_distributionrust-analyzer cargo palette 0.7.6 macros/random/test_uniform_distribution!! {
1595 Rgb<Srgb, f32> {
1596 red: (0.0, 1.0),
1597 green: (0.0, 1.0),
1598 blue: (0.0, 1.0)
1599 },
1600 min: Rgb::new(0.0f32, 0.0, 0.0),
1601 max: Rgb::new(1.0, 1.0, 1.0)
1602 }
1603 }