30 lines
No EOL
18 KiB
HTML
30 lines
No EOL
18 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="Marker trait for types that can be represented as an unsigned integer."><title>UintCast in 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 trait"><!--[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="#">Uint<wbr>Cast</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#safety" title="Safety">Safety</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Uint" title="Uint">Uint</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In cosmic::<wbr>cosmic_<wbr>theme::<wbr>palette::<wbr>cast</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>::<wbr><a href="index.html">cast</a></div><h1>Trait <span class="trait">UintCast</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/cast/uint.rs.html#31">Source</a> </span></div><pre class="rust item-decl"><code>pub unsafe trait UintCast {
|
||
type <a href="#associatedtype.Uint" class="associatedtype">Uint</a>;
|
||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Marker trait for types that can be represented as an unsigned integer.</p>
|
||
<p>A type that implements this trait is assumed to have the exact same memory
|
||
layout and representation as an unsigned integer, with the current compile
|
||
target’s endianness. This implies a couple of useful properties:</p>
|
||
<ul>
|
||
<li>Casting between <code>T</code> and <code>T::Uint</code> is free and will (or should) be
|
||
optimized away.</li>
|
||
<li><code>[T]</code> can be cast to and from <code>[T::Uint]</code>.</li>
|
||
</ul>
|
||
<p>This allows a number of common and useful optimizations, including casting
|
||
buffers and reusing memory. It does however come with some strict
|
||
requirements.</p>
|
||
<h3 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h3>
|
||
<ul>
|
||
<li>The type must be inhabited (eg: no
|
||
<a href="../../../iced/enum.Never.html" title="enum cosmic::iced::Never">Infallible</a>).</li>
|
||
<li>The type must allow any bit pattern (eg: either no requirements or some
|
||
ability to recover from invalid values).</li>
|
||
<li>The type must be either a wrapper around <code>Self::Uint</code> or be safe to transmute to and from <code>Self::Uint</code>.</li>
|
||
<li>The type must not contain any internal padding.</li>
|
||
<li>The type must be <code>repr(C)</code> or <code>repr(transparent)</code>.</li>
|
||
<li>The type must have the same size and alignment as <code>Self::Uint</code>.</li>
|
||
</ul>
|
||
<p>Note also that the type is assumed to not implement <code>Drop</code>. This will
|
||
rarely, if ever, be an issue. The requirements above ensures that the
|
||
underlying field types stay the same and will be dropped.</p>
|
||
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Uint" class="method"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/uint.rs.html#33">Source</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a></h4></section></summary><div class="docblock"><p>An unsigned integer with the same size as <code>Self</code>.</p>
|
||
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Packed%3CO,+u8%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#124">Source</a><a href="#impl-UintCast-for-Packed%3CO,+u8%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="struct.Packed.html" title="struct cosmic::cosmic_theme::palette::cast::Packed">Packed</a><O, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-1" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#125">Source</a><a href="#associatedtype.Uint-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Packed%3CO,+u16%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#132">Source</a><a href="#impl-UintCast-for-Packed%3CO,+u16%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="struct.Packed.html" title="struct cosmic::cosmic_theme::palette::cast::Packed">Packed</a><O, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-2" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#133">Source</a><a href="#associatedtype.Uint-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Packed%3CO,+u32%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#140">Source</a><a href="#impl-UintCast-for-Packed%3CO,+u32%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="struct.Packed.html" title="struct cosmic::cosmic_theme::palette::cast::Packed">Packed</a><O, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-3" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#141">Source</a><a href="#associatedtype.Uint-3" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Packed%3CO,+u64%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#148">Source</a><a href="#impl-UintCast-for-Packed%3CO,+u64%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="struct.Packed.html" title="struct cosmic::cosmic_theme::palette::cast::Packed">Packed</a><O, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-4" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#149">Source</a><a href="#associatedtype.Uint-4" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Packed%3CO,+u128%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#156">Source</a><a href="#impl-UintCast-for-Packed%3CO,+u128%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="struct.Packed.html" title="struct cosmic::cosmic_theme::palette::cast::Packed">Packed</a><O, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-5" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/cast/packed.rs.html#157">Source</a><a href="#associatedtype.Uint-5" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Luma%3CS,+u8%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#274">Source</a><a href="#impl-UintCast-for-Luma%3CS,+u8%3E" class="anchor">§</a><h3 class="code-header">impl<S> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="../luma/struct.Luma.html" title="struct cosmic::cosmic_theme::palette::luma::Luma">Luma</a><S, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-6" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#275">Source</a><a href="#associatedtype.Uint-6" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Luma%3CS,+u16%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#282">Source</a><a href="#impl-UintCast-for-Luma%3CS,+u16%3E" class="anchor">§</a><h3 class="code-header">impl<S> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="../luma/struct.Luma.html" title="struct cosmic::cosmic_theme::palette::luma::Luma">Luma</a><S, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-7" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#283">Source</a><a href="#associatedtype.Uint-7" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Luma%3CS,+u32%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#290">Source</a><a href="#impl-UintCast-for-Luma%3CS,+u32%3E" class="anchor">§</a><h3 class="code-header">impl<S> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="../luma/struct.Luma.html" title="struct cosmic::cosmic_theme::palette::luma::Luma">Luma</a><S, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-8" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#291">Source</a><a href="#associatedtype.Uint-8" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Luma%3CS,+u64%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#298">Source</a><a href="#impl-UintCast-for-Luma%3CS,+u64%3E" class="anchor">§</a><h3 class="code-header">impl<S> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="../luma/struct.Luma.html" title="struct cosmic::cosmic_theme::palette::luma::Luma">Luma</a><S, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-9" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#299">Source</a><a href="#associatedtype.Uint-9" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-UintCast-for-Luma%3CS,+u128%3E" class="impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#306">Source</a><a href="#impl-UintCast-for-Luma%3CS,+u128%3E" class="anchor">§</a><h3 class="code-header">impl<S> <a class="trait" href="trait.UintCast.html" title="trait cosmic::cosmic_theme::palette::cast::UintCast">UintCast</a> for <a class="struct" href="../luma/struct.Luma.html" title="struct cosmic::cosmic_theme::palette::luma::Luma">Luma</a><S, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>></h3></section></summary><div class="impl-items"><section id="associatedtype.Uint-10" class="associatedtype trait-impl"><a class="src rightside" href="https://docs.rs/palette/0.7.6/src/palette/luma/luma.rs.html#307">Source</a><a href="#associatedtype.Uint-10" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Uint" class="associatedtype">Uint</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></h4></section></div></details></div><script src="../../../../trait.impl/palette/cast/uint/trait.UintCast.js" data-ignore-extern-crates="palette" async></script></section></div></main></body></html> |