155 lines
No EOL
38 KiB
HTML
155 lines
No EOL
38 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Traits and functions for casting colors to and from other data types."><title>cosmic::cosmic_theme::palette::cast - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../../static.files/rustdoc-aa0817cf.css"><meta name="rustdoc-vars" data-root-path="../../../../" data-static-root-path="../../../../static.files/" data-current-crate="cosmic" data-themes="" data-resource-suffix="" data-rustdoc-version="1.90.0-nightly (3048886e5 2025-07-30)" data-channel="nightly" data-search-js="search-fa3e91e5.js" data-settings-js="settings-5514c975.js" ><script src="../../../../static.files/storage-68b7e25d.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../../../static.files/main-eebb9057.js"></script><noscript><link rel="stylesheet" href="../../../../static.files/noscript-32bb7600.css"></noscript><link rel="alternate icon" type="image/png" href="../../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../../../cosmic/index.html">cosmic</a><span class="version">1.0.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module cast</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#traits-or-functions" title="Traits or Functions?">Traits or Functions?</a></li><li><a href="#arrays-and-slices" title="Arrays and Slices">Arrays and Slices</a><ul><li><a href="#casting-arrays" title="Casting Arrays">Casting Arrays</a></li><li><a href="#casting-component-buffers" title="Casting Component Buffers">Casting Component Buffers</a></li><li><a href="#casting-single-colors" title="Casting Single Colors">Casting Single Colors</a></li><li><a href="#component-order" title="Component Order">Component Order</a></li></ul></li><li><a href="#unsigned-integers" title="Unsigned Integers">Unsigned Integers</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li><li><a href="#derives" title="Derive Macros">Derive Macros</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="../index.html">In cosmic::<wbr>cosmic_<wbr>theme::<wbr>palette</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../../../index.html">cosmic</a>::<wbr><a href="../../index.html">cosmic_theme</a>::<wbr><a href="../index.html">palette</a></div><h1>Module <span>cast</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="https://docs.rs/palette/0.7.6/src/palette/lib.rs.html#348">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Traits and functions for casting colors to and from other data types.</p>
|
||
<p>The functions and traits in this module cast without changing the underlying
|
||
data. See the <a href="../convert/index.html" title="mod cosmic::cosmic_theme::palette::convert"><code>convert</code></a> module for how to convert between
|
||
color spaces.</p>
|
||
<h2 id="traits-or-functions"><a class="doc-anchor" href="#traits-or-functions">§</a>Traits or Functions?</h2>
|
||
<p>This module provides both a set of traits (<a href="trait.FromComponents.html" title="trait cosmic::cosmic_theme::palette::cast::FromComponents"><code>FromComponents</code></a>,
|
||
<a href="trait.IntoUints.html" title="trait cosmic::cosmic_theme::palette::cast::IntoUints"><code>IntoUints</code></a>, etc.) and a set of functions (<a href="fn.from_component_slice.html" title="fn cosmic::cosmic_theme::palette::cast::from_component_slice"><code>from_component_slice</code></a>,
|
||
<a href="fn.into_uint_array.html" title="fn cosmic::cosmic_theme::palette::cast::into_uint_array"><code>into_uint_array</code></a>, etc.) that effectively implement the same
|
||
functionality. The traits are all implemented using the functions, so they
|
||
can be seen as bits of more implicit syntax sugar for the more explicit
|
||
functions.</p>
|
||
<p>A general recommendation is to use the traits, since they provide mostly
|
||
better ergonomics.</p>
|
||
<h2 id="arrays-and-slices"><a class="doc-anchor" href="#arrays-and-slices">§</a>Arrays and Slices</h2>
|
||
<p>Types that implement <a href="trait.ArrayCast.html" title="trait cosmic::cosmic_theme::palette::cast::ArrayCast"><code>ArrayCast</code></a> can be cast to and from arrays and slices
|
||
with little to no overhead. This makes it easy to work with image buffers
|
||
and types from other crates without having to copy the data first.</p>
|
||
<p>Casting can be either be done with the free functions in this module, or
|
||
using the helper traits.</p>
|
||
<h3 id="casting-arrays"><a class="doc-anchor" href="#casting-arrays">§</a>Casting Arrays</h3>
|
||
<p>Arrays can be type checked to have the correct size at compile time, making
|
||
casting free after optimization has removed the overhead from asserts. The
|
||
same is true for arrays in slices and <code>Vec</code>s, because the length stays the
|
||
same after casting.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>palette::{cast::{<span class="self">self</span>, ArraysAsMut}, Srgb, IntoColor};
|
||
|
||
<span class="kw">let </span>color = cast::from_array::<Srgb<u8>>([<span class="number">23</span>, <span class="number">198</span>, <span class="number">76</span>]).into_linear();
|
||
<span class="comment">// Note: `Srgb::<u8>::from([23, 198, 76])` works too.
|
||
|
||
</span><span class="kw">let </span><span class="kw-2">mut </span>buffer = [[<span class="number">64</span>, <span class="number">139</span>, <span class="number">10</span>], [<span class="number">93</span>, <span class="number">18</span>, <span class="number">214</span>]];
|
||
<span class="kw">let </span>color_buffer: <span class="kw-2">&mut </span>[Srgb<u8>] = buffer.arrays_as_mut();
|
||
|
||
<span class="kw">for </span>destination <span class="kw">in </span>color_buffer {
|
||
<span class="kw">let </span>linear_dst = destination.into_linear::<f32>();
|
||
<span class="kw-2">*</span>destination = (linear_dst + color).into_encoding();
|
||
}</code></pre></div>
|
||
<p>Trying to cast a single array of the wrong size will not compile:</p>
|
||
|
||
<div class="example-wrap compile_fail"><a href="#" class="tooltip" title="This example deliberately fails to compile">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>palette::{cast, Srgb};
|
||
|
||
<span class="kw">let </span>color = cast::from_array::<Srgb<u8>>([<span class="number">23</span>, <span class="number">198</span>]); <span class="comment">// Too few components.</span></code></pre></div>
|
||
<h3 id="casting-component-buffers"><a class="doc-anchor" href="#casting-component-buffers">§</a>Casting Component Buffers</h3>
|
||
<p>This is a common situation is image processing, where you have an image
|
||
buffer, such as <code>&mut [u8]</code>, <code>&mut [f32]</code>, <code>Vec<u8></code> or <code>Vec<f32></code>, that you
|
||
want to work with as colors. This buffer may, for example, be the content of
|
||
an image file or shared with the GPU.</p>
|
||
<p>The downside, compared to having fixed size arrays, is that the length
|
||
cannot be statically known to be a multiple of the color type’s array
|
||
length. This adds a bit of error handling overhead, as well as for dividing
|
||
or multiplying the length.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>palette::{cast::{<span class="self">self</span>, TryComponentsAs}, Srgb};
|
||
|
||
<span class="kw">let </span>correct_buffer = [<span class="number">64</span>, <span class="number">139</span>, <span class="number">10</span>, <span class="number">93</span>, <span class="number">18</span>, <span class="number">214</span>];
|
||
<span class="kw">let </span>should_be_ok: <span class="prelude-ty">Result</span><<span class="kw-2">&</span>[Srgb<u8>], <span class="kw">_</span>> = correct_buffer.try_components_as();
|
||
<span class="macro">assert!</span>(should_be_ok.is_ok());
|
||
|
||
<span class="kw">let </span>incorrect_buffer = [<span class="number">64</span>, <span class="number">139</span>, <span class="number">10</span>, <span class="number">93</span>, <span class="number">18</span>, <span class="number">214</span>, <span class="number">198</span>, <span class="number">76</span>];
|
||
<span class="kw">let </span>should_be_err: <span class="prelude-ty">Result</span><<span class="kw-2">&</span>[Srgb<u8>], <span class="kw">_</span>> = incorrect_buffer.try_components_as();
|
||
<span class="macro">assert!</span>(should_be_err.is_err());</code></pre></div>
|
||
<p>An alternative, for when the length can be trusted to be correct, is to use
|
||
methods without the <code>try_*</code> prefix, such as <code>ComponentsAs::components_as</code>,
|
||
or the <code>from_component_*</code> functions, that panic on error.</p>
|
||
<p>This works:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>palette::{cast::ComponentsAs, Srgb};
|
||
|
||
<span class="kw">let </span>correct_buffer = [<span class="number">64</span>, <span class="number">139</span>, <span class="number">10</span>, <span class="number">93</span>, <span class="number">18</span>, <span class="number">214</span>];
|
||
<span class="kw">let </span>color_buffer: <span class="kw-2">&</span>[Srgb<u8>] = correct_buffer.components_as();</code></pre></div>
|
||
<p>But this panics:</p>
|
||
|
||
<div class="example-wrap should_panic"><a href="#" class="tooltip" title="This example panics">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>palette::{cast::ComponentsAs, Srgb};
|
||
|
||
<span class="kw">let </span>incorrect_buffer = [<span class="number">64</span>, <span class="number">139</span>, <span class="number">10</span>, <span class="number">93</span>, <span class="number">18</span>, <span class="number">214</span>, <span class="number">198</span>, <span class="number">76</span>];
|
||
<span class="kw">let </span>color_buffer: <span class="kw-2">&</span>[Srgb<u8>] = incorrect_buffer.components_as();</code></pre></div>
|
||
<h3 id="casting-single-colors"><a class="doc-anchor" href="#casting-single-colors">§</a>Casting Single Colors</h3>
|
||
<p>The built-in color types implement <code>AsRef</code>, <code>AsMut</code>, <code>From</code>, <code>Into</code>,
|
||
<code>TryFrom</code> and <code>TryInto</code> in addition to <code>ArrayCast</code> for convenient casting of
|
||
single colors:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>core::convert::TryFrom;
|
||
<span class="kw">use </span>palette::Srgb;
|
||
|
||
<span class="kw">let </span>color = Srgb::from([<span class="number">23u8</span>, <span class="number">198</span>, <span class="number">76</span>]);
|
||
<span class="kw">let </span>array: [u8; <span class="number">3</span>] = color.into();
|
||
|
||
<span class="kw">let </span>slice: <span class="kw-2">&</span>[u8] = color.as_ref();
|
||
<span class="macro">assert!</span>(<<span class="kw-2">&</span>Srgb<u8>>::try_from(slice).is_ok());
|
||
|
||
<span class="kw">let </span>short_slice: <span class="kw-2">&</span>[f32] = <span class="kw-2">&</span>[<span class="number">0.1</span>, <span class="number">0.5</span>];
|
||
<span class="macro">assert!</span>(<<span class="kw-2">&</span>Srgb>::try_from(short_slice).is_err()); <span class="comment">// Too few components.</span></code></pre></div>
|
||
<h3 id="component-order"><a class="doc-anchor" href="#component-order">§</a>Component Order</h3>
|
||
<p>The component order in an array or slice is not always the same as in the
|
||
color types. For example, a byte buffer that is encoded as ARGB will not
|
||
cast to correct <code>Rgba</code> values. The components can be reordered after casting
|
||
by using the <a href="struct.Packed.html" title="struct cosmic::cosmic_theme::palette::cast::Packed"><code>Packed</code></a> wrapper as an intermediate representation.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// `PackedArgb` is an alias for `Packed<rgb::channels::Argb, P = u32>`.
|
||
</span><span class="kw">use </span>palette::{rgb::PackedArgb, cast::ComponentsAs, Srgba};
|
||
|
||
<span class="kw">let </span>components = [<span class="number">1.0f32</span>, <span class="number">0.8</span>, <span class="number">0.2</span>, <span class="number">0.3</span>, <span class="number">1.0</span>, <span class="number">0.5</span>, <span class="number">0.7</span>, <span class="number">0.6</span>];
|
||
<span class="kw">let </span>colors: <span class="kw-2">&</span>[PackedArgb<<span class="kw">_</span>>] = components.components_as();
|
||
|
||
<span class="comment">// Notice how the alpha values have moved from the beginning to the end:
|
||
</span><span class="macro">assert_eq!</span>(Srgba::from(colors[<span class="number">0</span>]), Srgba::new(<span class="number">0.8</span>, <span class="number">0.2</span>, <span class="number">0.3</span>, <span class="number">1.0</span>));
|
||
<span class="macro">assert_eq!</span>(Srgba::from(colors[<span class="number">1</span>]), Srgba::new(<span class="number">0.5</span>, <span class="number">0.7</span>, <span class="number">0.6</span>, <span class="number">1.0</span>));</code></pre></div>
|
||
<h2 id="unsigned-integers"><a class="doc-anchor" href="#unsigned-integers">§</a>Unsigned Integers</h2>
|
||
<p>Types that implement <a href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast"><code>UintCast</code></a> can be cast to and from unsigned integers
|
||
of the same size. It’s a bit more limited than slices and arrays but it’s
|
||
useful for common patterns like representing RGBA values as hexadecimal
|
||
unsigned integers.</p>
|
||
<p>The <a href="struct.Packed.html" title="struct cosmic::cosmic_theme::palette::cast::Packed"><code>Packed</code></a> wrapper can be used as an intermediate format to make
|
||
unpacking the values as simple as <code>from</code> or <code>into</code>. It’s also possible to
|
||
choose a channel order to be something other than what the default <code>From</code>
|
||
implementations would use.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// `PackedArgb` is an alias for `Packed<rgb::channels::Argb, P = u32>`.
|
||
</span><span class="kw">use </span>palette::{rgb::PackedArgb, cast::UintsAs, Srgba};
|
||
|
||
<span class="kw">let </span>raw = [<span class="number">0xFF7F0080u32</span>, <span class="number">0xFF60BBCC</span>];
|
||
<span class="kw">let </span>colors: <span class="kw-2">&</span>[PackedArgb] = raw.uints_as();
|
||
|
||
<span class="macro">assert_eq!</span>(colors.len(), <span class="number">2</span>);
|
||
<span class="macro">assert_eq!</span>(Srgba::from(colors[<span class="number">0</span>]), Srgba::new(<span class="number">0x7F</span>, <span class="number">0x00</span>, <span class="number">0x80</span>, <span class="number">0xFF</span>));
|
||
<span class="macro">assert_eq!</span>(Srgba::from(colors[<span class="number">1</span>]), Srgba::new(<span class="number">0x60</span>, <span class="number">0xBB</span>, <span class="number">0xCC</span>, <span class="number">0xFF</span>));</code></pre></div>
|
||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.BoxedSliceCastError.html" title="struct cosmic::cosmic_theme::palette::cast::BoxedSliceCastError">Boxed<wbr>Slice<wbr>Cast<wbr>Error</a></dt><dd>The error type returned when casting a boxed slice of components fails.</dd><dt><a class="struct" href="struct.Packed.html" title="struct cosmic::cosmic_theme::palette::cast::Packed">Packed</a></dt><dd>A color packed into a compact format, such as an unsigned integer.</dd><dt><a class="struct" href="struct.SliceCastError.html" title="struct cosmic::cosmic_theme::palette::cast::SliceCastError">Slice<wbr>Cast<wbr>Error</a></dt><dd>The error type returned when casting a slice of components fails.</dd><dt><a class="struct" href="struct.VecCastError.html" title="struct cosmic::cosmic_theme::palette::cast::VecCastError">VecCast<wbr>Error</a></dt><dd>The error type returned when casting a <code>Vec</code> of components fails.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.VecCastErrorKind.html" title="enum cosmic::cosmic_theme::palette::cast::VecCastErrorKind">VecCast<wbr>Error<wbr>Kind</a></dt><dd>The type of error that is returned when casting a <code>Vec</code> of components.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.ArrayCast.html" title="trait cosmic::cosmic_theme::palette::cast::ArrayCast">Array<wbr>Cast</a></dt><dd>Marker trait for types that can be represented as a fixed size array.</dd><dt><a class="trait" href="trait.ArraysAs.html" title="trait cosmic::cosmic_theme::palette::cast::ArraysAs">Arrays<wbr>As</a></dt><dd>Trait for casting a reference to collection of arrays into a reference to
|
||
collection of colors without copying.</dd><dt><a class="trait" href="trait.ArraysAsMut.html" title="trait cosmic::cosmic_theme::palette::cast::ArraysAsMut">Arrays<wbr>AsMut</a></dt><dd>Trait for casting a mutable reference to collection of arrays into a mutable
|
||
reference to collection of colors without copying.</dd><dt><a class="trait" href="trait.ArraysFrom.html" title="trait cosmic::cosmic_theme::palette::cast::ArraysFrom">Arrays<wbr>From</a></dt><dd>Trait for casting a collection of arrays from a collection of colors without
|
||
copying.</dd><dt><a class="trait" href="trait.ArraysInto.html" title="trait cosmic::cosmic_theme::palette::cast::ArraysInto">Arrays<wbr>Into</a></dt><dd>Trait for casting a collection of arrays into a collection of colors
|
||
without copying.</dd><dt><a class="trait" href="trait.AsArrays.html" title="trait cosmic::cosmic_theme::palette::cast::AsArrays">AsArrays</a></dt><dd>Trait for casting a reference to a collection of colors into a reference to
|
||
a collection of arrays without copying.</dd><dt><a class="trait" href="trait.AsArraysMut.html" title="trait cosmic::cosmic_theme::palette::cast::AsArraysMut">AsArrays<wbr>Mut</a></dt><dd>Trait for casting a mutable reference to a collection of colors into a
|
||
mutable reference to a collection of arrays without copying.</dd><dt><a class="trait" href="trait.AsComponents.html" title="trait cosmic::cosmic_theme::palette::cast::AsComponents">AsComponents</a></dt><dd>Trait for casting a reference to a collection of colors into a reference to
|
||
a collection of color components without copying.</dd><dt><a class="trait" href="trait.AsComponentsMut.html" title="trait cosmic::cosmic_theme::palette::cast::AsComponentsMut">AsComponents<wbr>Mut</a></dt><dd>Trait for casting a mutable reference to a collection of colors into a
|
||
mutable reference to a collection of color components without copying.</dd><dt><a class="trait" href="trait.AsUints.html" title="trait cosmic::cosmic_theme::palette::cast::AsUints">AsUints</a></dt><dd>Trait for casting a reference to a collection of colors into a reference to
|
||
a collection of unsigned integers without copying.</dd><dt><a class="trait" href="trait.AsUintsMut.html" title="trait cosmic::cosmic_theme::palette::cast::AsUintsMut">AsUints<wbr>Mut</a></dt><dd>Trait for casting a mutable reference to a collection of colors into a
|
||
mutable reference to a collection of unsigned integers without copying.</dd><dt><a class="trait" href="trait.ComponentOrder.html" title="trait cosmic::cosmic_theme::palette::cast::ComponentOrder">Component<wbr>Order</a></dt><dd>Packs and unpacks color types with some component order.</dd><dt><a class="trait" href="trait.ComponentsAs.html" title="trait cosmic::cosmic_theme::palette::cast::ComponentsAs">Components<wbr>As</a></dt><dd>Trait for casting a reference to collection of color components into a
|
||
reference to collection of colors without copying.</dd><dt><a class="trait" href="trait.ComponentsAsMut.html" title="trait cosmic::cosmic_theme::palette::cast::ComponentsAsMut">Components<wbr>AsMut</a></dt><dd>Trait for casting a mutable reference to collection of color components into
|
||
a mutable reference to collection of colors without copying.</dd><dt><a class="trait" href="trait.ComponentsFrom.html" title="trait cosmic::cosmic_theme::palette::cast::ComponentsFrom">Components<wbr>From</a></dt><dd>Trait for casting a collection of color components into a collection of
|
||
colors without copying.</dd><dt><a class="trait" href="trait.ComponentsInto.html" title="trait cosmic::cosmic_theme::palette::cast::ComponentsInto">Components<wbr>Into</a></dt><dd>Trait for casting a collection of color components from a collection of
|
||
colors without copying.</dd><dt><a class="trait" href="trait.FromArrays.html" title="trait cosmic::cosmic_theme::palette::cast::FromArrays">From<wbr>Arrays</a></dt><dd>Trait for casting a collection of colors from a collection of arrays without
|
||
copying.</dd><dt><a class="trait" href="trait.FromComponents.html" title="trait cosmic::cosmic_theme::palette::cast::FromComponents">From<wbr>Components</a></dt><dd>Trait for casting a collection of colors from a collection of color
|
||
components without copying.</dd><dt><a class="trait" href="trait.FromUints.html" title="trait cosmic::cosmic_theme::palette::cast::FromUints">From<wbr>Uints</a></dt><dd>Trait for casting a collection of colors from a collection of unsigned
|
||
integers without copying.</dd><dt><a class="trait" href="trait.IntoArrays.html" title="trait cosmic::cosmic_theme::palette::cast::IntoArrays">Into<wbr>Arrays</a></dt><dd>Trait for casting a collection of colors into a collection of arrays without
|
||
copying.</dd><dt><a class="trait" href="trait.IntoComponents.html" title="trait cosmic::cosmic_theme::palette::cast::IntoComponents">Into<wbr>Components</a></dt><dd>Trait for casting a collection of colors into a collection of color
|
||
components without copying.</dd><dt><a class="trait" href="trait.IntoUints.html" title="trait cosmic::cosmic_theme::palette::cast::IntoUints">Into<wbr>Uints</a></dt><dd>Trait for casting a collection of colors into a collection of unsigned
|
||
integers without copying.</dd><dt><a class="trait" href="trait.TryComponentsAs.html" title="trait cosmic::cosmic_theme::palette::cast::TryComponentsAs">TryComponents<wbr>As</a></dt><dd>Trait for trying to cast a reference to collection of color components into
|
||
a reference to collection of colors without copying.</dd><dt><a class="trait" href="trait.TryComponentsAsMut.html" title="trait cosmic::cosmic_theme::palette::cast::TryComponentsAsMut">TryComponents<wbr>AsMut</a></dt><dd>Trait for trying to cast a mutable reference to collection of color
|
||
components into a mutable reference to collection of colors without copying.</dd><dt><a class="trait" href="trait.TryComponentsInto.html" title="trait cosmic::cosmic_theme::palette::cast::TryComponentsInto">TryComponents<wbr>Into</a></dt><dd>Trait for trying to cast a collection of color components from a collection
|
||
of colors without copying.</dd><dt><a class="trait" href="trait.TryFromComponents.html" title="trait cosmic::cosmic_theme::palette::cast::TryFromComponents">TryFrom<wbr>Components</a></dt><dd>Trait for trying to cast a collection of colors from a collection of color
|
||
components without copying.</dd><dt><a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">Uint<wbr>Cast</a></dt><dd>Marker trait for types that can be represented as an unsigned integer.</dd><dt><a class="trait" href="trait.UintsAs.html" title="trait cosmic::cosmic_theme::palette::cast::UintsAs">UintsAs</a></dt><dd>Trait for casting a reference to a collection of unsigned integers into a
|
||
reference to a collection of colors without copying.</dd><dt><a class="trait" href="trait.UintsAsMut.html" title="trait cosmic::cosmic_theme::palette::cast::UintsAsMut">Uints<wbr>AsMut</a></dt><dd>Trait for casting a mutable reference to a collection of unsigned integers
|
||
into a mutable reference to a collection of colors without copying.</dd><dt><a class="trait" href="trait.UintsFrom.html" title="trait cosmic::cosmic_theme::palette::cast::UintsFrom">Uints<wbr>From</a></dt><dd>Trait for casting a collection of unsigned integers from a collection of
|
||
colors without copying.</dd><dt><a class="trait" href="trait.UintsInto.html" title="trait cosmic::cosmic_theme::palette::cast::UintsInto">Uints<wbr>Into</a></dt><dd>Trait for casting a collection of unsigned integers into a collection of
|
||
colors without copying.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.from_array.html" title="fn cosmic::cosmic_theme::palette::cast::from_array">from_<wbr>array</a></dt><dd>Cast from an array to a color type.</dd><dt><a class="fn" href="fn.from_array_array.html" title="fn cosmic::cosmic_theme::palette::cast::from_array_array">from_<wbr>array_<wbr>array</a></dt><dd>Cast from an array of arrays to an array of colors.</dd><dt><a class="fn" href="fn.from_array_box.html" title="fn cosmic::cosmic_theme::palette::cast::from_array_box">from_<wbr>array_<wbr>box</a></dt><dd>Cast from a boxed array to a boxed color type.</dd><dt><a class="fn" href="fn.from_array_mut.html" title="fn cosmic::cosmic_theme::palette::cast::from_array_mut">from_<wbr>array_<wbr>mut</a></dt><dd>Cast from a mutable array reference to a mutable color type reference.</dd><dt><a class="fn" href="fn.from_array_ref.html" title="fn cosmic::cosmic_theme::palette::cast::from_array_ref">from_<wbr>array_<wbr>ref</a></dt><dd>Cast from an array reference to a color type reference.</dd><dt><a class="fn" href="fn.from_array_slice.html" title="fn cosmic::cosmic_theme::palette::cast::from_array_slice">from_<wbr>array_<wbr>slice</a></dt><dd>Cast from a slice of arrays to a slice of colors.</dd><dt><a class="fn" href="fn.from_array_slice_box.html" title="fn cosmic::cosmic_theme::palette::cast::from_array_slice_box">from_<wbr>array_<wbr>slice_<wbr>box</a></dt><dd>Cast from a boxed slice of arrays to a boxed slice of colors.</dd><dt><a class="fn" href="fn.from_array_slice_mut.html" title="fn cosmic::cosmic_theme::palette::cast::from_array_slice_mut">from_<wbr>array_<wbr>slice_<wbr>mut</a></dt><dd>Cast from a mutable slice of arrays to a mutable slice of colors.</dd><dt><a class="fn" href="fn.from_array_vec.html" title="fn cosmic::cosmic_theme::palette::cast::from_array_vec">from_<wbr>array_<wbr>vec</a></dt><dd>Cast from a <code>Vec</code> of arrays to a <code>Vec</code> of colors.</dd><dt><a class="fn" href="fn.from_component_array.html" title="fn cosmic::cosmic_theme::palette::cast::from_component_array">from_<wbr>component_<wbr>array</a></dt><dd>Cast from an array of color components to an array of colors.</dd><dt><a class="fn" href="fn.from_component_slice.html" title="fn cosmic::cosmic_theme::palette::cast::from_component_slice">from_<wbr>component_<wbr>slice</a></dt><dd>The same as <a href="fn.try_from_component_slice.html" title="fn cosmic::cosmic_theme::palette::cast::try_from_component_slice"><code>try_from_component_slice</code></a> but panics on error.</dd><dt><a class="fn" href="fn.from_component_slice_box.html" title="fn cosmic::cosmic_theme::palette::cast::from_component_slice_box">from_<wbr>component_<wbr>slice_<wbr>box</a></dt><dd>The same as <a href="fn.try_from_component_slice_box.html" title="fn cosmic::cosmic_theme::palette::cast::try_from_component_slice_box"><code>try_from_component_slice_box</code></a> but panics on error.</dd><dt><a class="fn" href="fn.from_component_slice_mut.html" title="fn cosmic::cosmic_theme::palette::cast::from_component_slice_mut">from_<wbr>component_<wbr>slice_<wbr>mut</a></dt><dd>The same as <a href="fn.try_from_component_slice_mut.html" title="fn cosmic::cosmic_theme::palette::cast::try_from_component_slice_mut"><code>try_from_component_slice_mut</code></a> but panics on error.</dd><dt><a class="fn" href="fn.from_component_vec.html" title="fn cosmic::cosmic_theme::palette::cast::from_component_vec">from_<wbr>component_<wbr>vec</a></dt><dd>The same as <a href="fn.try_from_component_vec.html" title="fn cosmic::cosmic_theme::palette::cast::try_from_component_vec"><code>try_from_component_vec</code></a> but panics on error.</dd><dt><a class="fn" href="fn.from_uint.html" title="fn cosmic::cosmic_theme::palette::cast::from_uint">from_<wbr>uint</a></dt><dd>Cast from an unsigned integer to a color type.</dd><dt><a class="fn" href="fn.from_uint_array.html" title="fn cosmic::cosmic_theme::palette::cast::from_uint_array">from_<wbr>uint_<wbr>array</a></dt><dd>Cast from an array of unsigned integers to an array of colors.</dd><dt><a class="fn" href="fn.from_uint_mut.html" title="fn cosmic::cosmic_theme::palette::cast::from_uint_mut">from_<wbr>uint_<wbr>mut</a></dt><dd>Cast from a mutable unsigned integer reference to a mutable color type reference.</dd><dt><a class="fn" href="fn.from_uint_ref.html" title="fn cosmic::cosmic_theme::palette::cast::from_uint_ref">from_<wbr>uint_<wbr>ref</a></dt><dd>Cast from an unsigned integer reference to a color type reference.</dd><dt><a class="fn" href="fn.from_uint_slice.html" title="fn cosmic::cosmic_theme::palette::cast::from_uint_slice">from_<wbr>uint_<wbr>slice</a></dt><dd>Cast from a slice of unsigned integers to a slice of colors.</dd><dt><a class="fn" href="fn.from_uint_slice_box.html" title="fn cosmic::cosmic_theme::palette::cast::from_uint_slice_box">from_<wbr>uint_<wbr>slice_<wbr>box</a></dt><dd>Cast from a boxed slice of unsigned integers to a boxed slice of colors.</dd><dt><a class="fn" href="fn.from_uint_slice_mut.html" title="fn cosmic::cosmic_theme::palette::cast::from_uint_slice_mut">from_<wbr>uint_<wbr>slice_<wbr>mut</a></dt><dd>Cast from a mutable slice of unsigned integers to a mutable slice of colors.</dd><dt><a class="fn" href="fn.from_uint_vec.html" title="fn cosmic::cosmic_theme::palette::cast::from_uint_vec">from_<wbr>uint_<wbr>vec</a></dt><dd>Cast from a <code>Vec</code> of unsigned integers to a <code>Vec</code> of colors.</dd><dt><a class="fn" href="fn.into_array.html" title="fn cosmic::cosmic_theme::palette::cast::into_array">into_<wbr>array</a></dt><dd>Cast from a color type to an array.</dd><dt><a class="fn" href="fn.into_array_array.html" title="fn cosmic::cosmic_theme::palette::cast::into_array_array">into_<wbr>array_<wbr>array</a></dt><dd>Cast from an array of colors to an array of arrays.</dd><dt><a class="fn" href="fn.into_array_box.html" title="fn cosmic::cosmic_theme::palette::cast::into_array_box">into_<wbr>array_<wbr>box</a></dt><dd>Cast from a boxed color type to a boxed array.</dd><dt><a class="fn" href="fn.into_array_mut.html" title="fn cosmic::cosmic_theme::palette::cast::into_array_mut">into_<wbr>array_<wbr>mut</a></dt><dd>Cast from a mutable color type reference to a mutable array reference.</dd><dt><a class="fn" href="fn.into_array_ref.html" title="fn cosmic::cosmic_theme::palette::cast::into_array_ref">into_<wbr>array_<wbr>ref</a></dt><dd>Cast from a color type reference to an array reference.</dd><dt><a class="fn" href="fn.into_array_slice.html" title="fn cosmic::cosmic_theme::palette::cast::into_array_slice">into_<wbr>array_<wbr>slice</a></dt><dd>Cast from a slice of colors to a slice of arrays.</dd><dt><a class="fn" href="fn.into_array_slice_box.html" title="fn cosmic::cosmic_theme::palette::cast::into_array_slice_box">into_<wbr>array_<wbr>slice_<wbr>box</a></dt><dd>Cast from a boxed slice of colors to a boxed slice of arrays.</dd><dt><a class="fn" href="fn.into_array_slice_mut.html" title="fn cosmic::cosmic_theme::palette::cast::into_array_slice_mut">into_<wbr>array_<wbr>slice_<wbr>mut</a></dt><dd>Cast from a mutable slice of colors to a mutable slice of arrays.</dd><dt><a class="fn" href="fn.into_array_vec.html" title="fn cosmic::cosmic_theme::palette::cast::into_array_vec">into_<wbr>array_<wbr>vec</a></dt><dd>Cast from a <code>Vec</code> of colors to a <code>Vec</code> of arrays.</dd><dt><a class="fn" href="fn.into_component_array.html" title="fn cosmic::cosmic_theme::palette::cast::into_component_array">into_<wbr>component_<wbr>array</a></dt><dd>Cast from an array of colors to an array of color components.</dd><dt><a class="fn" href="fn.into_component_slice.html" title="fn cosmic::cosmic_theme::palette::cast::into_component_slice">into_<wbr>component_<wbr>slice</a></dt><dd>Cast from a slice of colors to a slice of color components.</dd><dt><a class="fn" href="fn.into_component_slice_box.html" title="fn cosmic::cosmic_theme::palette::cast::into_component_slice_box">into_<wbr>component_<wbr>slice_<wbr>box</a></dt><dd>Cast from a boxed slice of colors to a boxed slice of color components.</dd><dt><a class="fn" href="fn.into_component_slice_mut.html" title="fn cosmic::cosmic_theme::palette::cast::into_component_slice_mut">into_<wbr>component_<wbr>slice_<wbr>mut</a></dt><dd>Cast from a slice of colors to a slice of color components.</dd><dt><a class="fn" href="fn.into_component_vec.html" title="fn cosmic::cosmic_theme::palette::cast::into_component_vec">into_<wbr>component_<wbr>vec</a></dt><dd>Cast from a <code>Vec</code> of colors to a <code>Vec</code> of color components.</dd><dt><a class="fn" href="fn.into_uint.html" title="fn cosmic::cosmic_theme::palette::cast::into_uint">into_<wbr>uint</a></dt><dd>Cast from a color type to an unsigned integer.</dd><dt><a class="fn" href="fn.into_uint_array.html" title="fn cosmic::cosmic_theme::palette::cast::into_uint_array">into_<wbr>uint_<wbr>array</a></dt><dd>Cast from an array of colors to an array of unsigned integers.</dd><dt><a class="fn" href="fn.into_uint_mut.html" title="fn cosmic::cosmic_theme::palette::cast::into_uint_mut">into_<wbr>uint_<wbr>mut</a></dt><dd>Cast from a mutable color type reference to a mutable unsigned integer reference.</dd><dt><a class="fn" href="fn.into_uint_ref.html" title="fn cosmic::cosmic_theme::palette::cast::into_uint_ref">into_<wbr>uint_<wbr>ref</a></dt><dd>Cast from a color type reference to an unsigned integer reference.</dd><dt><a class="fn" href="fn.into_uint_slice.html" title="fn cosmic::cosmic_theme::palette::cast::into_uint_slice">into_<wbr>uint_<wbr>slice</a></dt><dd>Cast from a slice of colors to a slice of unsigned integers.</dd><dt><a class="fn" href="fn.into_uint_slice_box.html" title="fn cosmic::cosmic_theme::palette::cast::into_uint_slice_box">into_<wbr>uint_<wbr>slice_<wbr>box</a></dt><dd>Cast from a boxed slice of colors to a boxed slice of unsigned integers.</dd><dt><a class="fn" href="fn.into_uint_slice_mut.html" title="fn cosmic::cosmic_theme::palette::cast::into_uint_slice_mut">into_<wbr>uint_<wbr>slice_<wbr>mut</a></dt><dd>Cast from a mutable slice of colors to a mutable slice of unsigned integers.</dd><dt><a class="fn" href="fn.into_uint_vec.html" title="fn cosmic::cosmic_theme::palette::cast::into_uint_vec">into_<wbr>uint_<wbr>vec</a></dt><dd>Cast from a <code>Vec</code> of colors to a <code>Vec</code> of unsigned integers.</dd><dt><a class="fn" href="fn.map_slice_box_in_place.html" title="fn cosmic::cosmic_theme::palette::cast::map_slice_box_in_place">map_<wbr>slice_<wbr>box_<wbr>in_<wbr>place</a></dt><dd>Map values of color A to values of color B without creating a new <code>Box<[B]></code>.</dd><dt><a class="fn" href="fn.map_vec_in_place.html" title="fn cosmic::cosmic_theme::palette::cast::map_vec_in_place">map_<wbr>vec_<wbr>in_<wbr>place</a></dt><dd>Map values of color A to values of color B without creating a new <code>Vec</code>.</dd><dt><a class="fn" href="fn.try_from_component_slice.html" title="fn cosmic::cosmic_theme::palette::cast::try_from_component_slice">try_<wbr>from_<wbr>component_<wbr>slice</a></dt><dd>Cast from a slice of color components to a slice of colors.</dd><dt><a class="fn" href="fn.try_from_component_slice_box.html" title="fn cosmic::cosmic_theme::palette::cast::try_from_component_slice_box">try_<wbr>from_<wbr>component_<wbr>slice_<wbr>box</a></dt><dd>Cast from a boxed slice of color components to a boxed slice of colors.</dd><dt><a class="fn" href="fn.try_from_component_slice_mut.html" title="fn cosmic::cosmic_theme::palette::cast::try_from_component_slice_mut">try_<wbr>from_<wbr>component_<wbr>slice_<wbr>mut</a></dt><dd>Cast from a mutable slice of color components to a slice of colors.</dd><dt><a class="fn" href="fn.try_from_component_vec.html" title="fn cosmic::cosmic_theme::palette::cast::try_from_component_vec">try_<wbr>from_<wbr>component_<wbr>vec</a></dt><dd>Cast from a <code>Vec</code> of color components to a <code>Vec</code> of colors.</dd></dl><h2 id="derives" class="section-header">Derive Macros<a href="#derives" class="anchor">§</a></h2><dl class="item-table"><dt><a class="derive" href="derive.ArrayCast.html" title="derive cosmic::cosmic_theme::palette::cast::ArrayCast">Array<wbr>Cast</a></dt></dl></section></div></main></body></html> |