You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rCore-Tutorial-v3-tests/ch6/zero/trait.Pod.html

28 lines
10 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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="Implementing this trait means that the concrete type is plain old data (POD). Precisely, by implementing `Pod` the programmer asserts that it is safe to read the type from binary slices provided to `read`, etc."><meta name="keywords" content="rust, rustlang, rust-lang, Pod"><title>Pod in zero - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script src="../crates.js"></script><script defer src="../main.js"></script>
<noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.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">&#9776;</button><a class="sidebar-logo" href="../zero/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
</a><h2 class="location"></h2>
</nav>
<nav class="sidebar"><a class="sidebar-logo" href="../zero/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div>
</a><h2 class="location"><a href="#">Pod</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul><li><a href="#impl-Pod-for-i16">i16</a></li><li><a href="#impl-Pod-for-i32">i32</a></li><li><a href="#impl-Pod-for-i64">i64</a></li><li><a href="#impl-Pod-for-i8">i8</a></li><li><a href="#impl-Pod-for-u16">u16</a></li><li><a href="#impl-Pod-for-u32">u32</a></li><li><a href="#impl-Pod-for-u64">u64</a></li><li><a href="#impl-Pod-for-u8">u8</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In zero</a></h2><div id="sidebar-vars" data-name="Pod" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../zero/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><div class="theme-picker hidden"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="22" height="22" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><div class="main-heading">
<h1 class="fqn"><span class="in-band">Trait <a href="index.html">zero</a>::<wbr><a class="trait" href="#">Pod</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/zero/lib.rs.html#94">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub unsafe trait Pod: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> { }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implementing this trait means that the concrete type is plain old data (POD).
Precisely, by implementing <code>Pod</code> the programmer asserts that it is safe to
read the type from binary slices provided to <code>read</code>, etc.</p>
<p>Some guidelines for when <code>Pod</code> may be implemented (note that whether <code>Pod</code>
should be implemented or not is a function of both the type and the input
data. I.e., just because a type is <code>Pod</code> in one context does not mean it
should be in another):</p>
<ul>
<li>primitive numeric types (<code>u8</code>, <code>i64</code>, <code>f32</code>, etc.) are fine,</li>
<li>bools are fine, if the provided data ensures they may have only the values
<code>0</code> or <code>1</code> (note that this is a stricter requirement that C),</li>
<li>structs containing only <code>Pod</code> data are fine,</li>
<li>structs must be <code>repr(C)</code> or <code>repr(packed)</code>, if the former, the supplied
data must have the correct alignment,</li>
<li>enums must have valid discriminants in the supplied data, this is probably
only feasible if they have a specified representation,</li>
<li>there must not be invalid enum variants in the data,</li>
<li>any kind of pointer is probably a bad idea. Theoretically one could make
raw pointers work.</li>
</ul>
</div></details><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><section id="impl-Pod-for-u8" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/zero/lib.rs.html#96">source</a></span><a href="#impl-Pod-for-u8" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Pod.html" title="trait zero::Pod">Pod</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u8.html">u8</a></h3></section><section id="impl-Pod-for-u16" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/zero/lib.rs.html#97">source</a></span><a href="#impl-Pod-for-u16" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Pod.html" title="trait zero::Pod">Pod</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u16.html">u16</a></h3></section><section id="impl-Pod-for-u32" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/zero/lib.rs.html#98">source</a></span><a href="#impl-Pod-for-u32" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Pod.html" title="trait zero::Pod">Pod</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u32.html">u32</a></h3></section><section id="impl-Pod-for-u64" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/zero/lib.rs.html#99">source</a></span><a href="#impl-Pod-for-u64" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Pod.html" title="trait zero::Pod">Pod</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.u64.html">u64</a></h3></section><section id="impl-Pod-for-i8" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/zero/lib.rs.html#100">source</a></span><a href="#impl-Pod-for-i8" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Pod.html" title="trait zero::Pod">Pod</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.i8.html">i8</a></h3></section><section id="impl-Pod-for-i16" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/zero/lib.rs.html#101">source</a></span><a href="#impl-Pod-for-i16" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Pod.html" title="trait zero::Pod">Pod</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.i16.html">i16</a></h3></section><section id="impl-Pod-for-i32" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/zero/lib.rs.html#102">source</a></span><a href="#impl-Pod-for-i32" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Pod.html" title="trait zero::Pod">Pod</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.i32.html">i32</a></h3></section><section id="impl-Pod-for-i64" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../src/zero/lib.rs.html#103">source</a></span><a href="#impl-Pod-for-i64" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Pod.html" title="trait zero::Pod">Pod</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/core/primitive.i64.html">i64</a></h3></section><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"></div><script type="text/javascript" src="../implementors/zero/trait.Pod.js" async></script></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="zero" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.62.0-nightly (1f7fb6413 2022-04-10)" ></div>
</body></html>