difftastic/rustdoc/allocator_api2/alloc/struct.Layout.html

173 lines
58 KiB
HTML

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="Layout of a block of memory."><title>Layout in allocator_api2::alloc - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-ac92e1bbe349e143.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="allocator_api2" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc struct"><!--[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></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../allocator_api2/index.html">allocator_api2</a><span class="version">0.2.16</span></h2></div><h2 class="location"><a href="#">Layout</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.align">align</a></li><li><a href="#method.align_to">align_to</a></li><li><a href="#method.array">array</a></li><li><a href="#method.dangling">dangling</a></li><li><a href="#method.extend">extend</a></li><li><a href="#method.extend_packed">extend_packed</a></li><li><a href="#method.for_value">for_value</a></li><li><a href="#method.for_value_raw">for_value_raw</a></li><li><a href="#method.from_size_align">from_size_align</a></li><li><a href="#method.from_size_align_unchecked">from_size_align_unchecked</a></li><li><a href="#method.new">new</a></li><li><a href="#method.pad_to_align">pad_to_align</a></li><li><a href="#method.padding_needed_for">padding_needed_for</a></li><li><a href="#method.repeat">repeat</a></li><li><a href="#method.repeat_packed">repeat_packed</a></li><li><a href="#method.size">size</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Clone-for-Layout">Clone</a></li><li><a href="#impl-Copy-for-Layout">Copy</a></li><li><a href="#impl-Debug-for-Layout">Debug</a></li><li><a href="#impl-Eq-for-Layout">Eq</a></li><li><a href="#impl-Hash-for-Layout">Hash</a></li><li><a href="#impl-PartialEq-for-Layout">PartialEq</a></li><li><a href="#impl-StructuralEq-for-Layout">StructuralEq</a></li><li><a href="#impl-StructuralPartialEq-for-Layout">StructuralPartialEq</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-Layout">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Layout">Send</a></li><li><a href="#impl-Sync-for-Layout">Sync</a></li><li><a href="#impl-Unpin-for-Layout">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Layout">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-T">From&lt;T&gt;</a></li><li><a href="#impl-Into%3CU%3E-for-T">Into&lt;U&gt;</a></li><li><a href="#impl-ToOwned-for-T">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto&lt;U&gt;</a></li></ul></section><h2><a href="index.html">In allocator_api2::alloc</a></h2></div></nav><div class="sidebar-resizer"></div>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../../allocator_api2/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="../index.html">allocator_api2</a>::<wbr><a href="index.html">alloc</a>::<wbr><a class="struct" href="#">Layout</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><span class="since" title="Stable since Rust version 1.28.0">1.28.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#38">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub struct Layout { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Layout of a block of memory.</p>
<p>An instance of <code>Layout</code> describes a particular layout of memory.
You build a <code>Layout</code> up as an input to give to an allocator.</p>
<p>All layouts have an associated size and a power-of-two alignment.</p>
<p>(Note that layouts are <em>not</em> required to have non-zero size,
even though <code>GlobalAlloc</code> requires that all memory requests
be non-zero in size. A caller must either ensure that conditions
like this are met, use specific allocators with looser
requirements, or use the more lenient <code>Allocator</code> interface.)</p>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Layout" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#52">source</a><a href="#impl-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from_size_align" class="method"><span class="rightside"><span class="since" title="const since 1.50.0">const: 1.50.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#68">source</a></span><h4 class="code-header">pub const fn <a href="#method.from_size_align" class="fn">from_size_align</a>(
size: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>,
align: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>, <a class="struct" href="struct.LayoutError.html" title="struct allocator_api2::alloc::LayoutError">LayoutError</a>&gt;</h4></section></summary><div class="docblock"><p>Constructs a <code>Layout</code> from a given <code>size</code> and <code>align</code>,
or returns <code>LayoutError</code> if any of the following conditions
are not met:</p>
<ul>
<li>
<p><code>align</code> must not be zero,</p>
</li>
<li>
<p><code>align</code> must be a power of two,</p>
</li>
<li>
<p><code>size</code>, when rounded up to the nearest multiple of <code>align</code>,
must not overflow isize (i.e., the rounded value must be
less than or equal to <code>isize::MAX</code>).</p>
</li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_size_align_unchecked" class="method"><span class="rightside"><span class="since" title="const since 1.36.0">const: 1.36.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#118">source</a></span><h4 class="code-header">pub const unsafe fn <a href="#method.from_size_align_unchecked" class="fn">from_size_align_unchecked</a>(
size: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>,
align: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>
) -&gt; <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h4></section></summary><div class="docblock"><p>Creates a layout, bypassing all checks.</p>
<h5 id="safety"><a href="#safety">Safety</a></h5>
<p>This function is unsafe as it does not verify the preconditions from
<a href="struct.Layout.html#method.from_size_align" title="associated function allocator_api2::alloc::Layout::from_size_align"><code>Layout::from_size_align</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.size" class="method"><span class="rightside"><span class="since" title="const since 1.50.0">const: 1.50.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#128">source</a></span><h4 class="code-header">pub const fn <a href="#method.size" class="fn">size</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>The minimum size in bytes for a memory block of this layout.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.align" class="method"><span class="rightside"><span class="since" title="const since 1.50.0">const: 1.50.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#141">source</a></span><h4 class="code-header">pub const fn <a href="#method.align" class="fn">align</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>The minimum byte alignment for a memory block of this layout.</p>
<p>The returned alignment is guaranteed to be a power of two.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><span class="rightside"><span class="since" title="const since 1.42.0">const: 1.42.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#150">source</a></span><h4 class="code-header">pub const fn <a href="#method.new" class="fn">new</a>&lt;T&gt;() -&gt; <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h4></section></summary><div class="docblock"><p>Constructs a <code>Layout</code> suitable for holding a value of type <code>T</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.for_value" class="method"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/67521" title="Tracking issue for const_alloc_layout">unstable</a></span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#165">source</a></span><h4 class="code-header">pub fn <a href="#method.for_value" class="fn">for_value</a>&lt;T&gt;(t: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;T</a>) -&gt; <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a><div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class="docblock"><p>Produces layout describing a record that could be used to
allocate backing structure for <code>T</code> (which could be a trait
or other unsized type like a slice).</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.for_value_raw" class="method"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/67521" title="Tracking issue for const_alloc_layout">unstable</a></span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#199">source</a></span><h4 class="code-header">pub unsafe fn <a href="#method.for_value_raw" class="fn">for_value_raw</a>&lt;T&gt;(t: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.pointer.html">*const T</a>) -&gt; <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a><div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>layout_for_ptr</code>)</span></div></span></summary><div class="docblock"><p>Produces layout describing a record that could be used to
allocate backing structure for <code>T</code> (which could be a trait
or other unsized type like a slice).</p>
<h5 id="safety-1"><a href="#safety-1">Safety</a></h5>
<p>This function is only safe to call if the following conditions hold:</p>
<ul>
<li>If <code>T</code> is <code>Sized</code>, this function is always safe to call.</li>
<li>If the unsized tail of <code>T</code> is:
<ul>
<li>a <a href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html" title="primitive slice">slice</a>, then the length of the slice tail must be an initialized
integer, and the size of the <em>entire value</em>
(dynamic tail length + statically sized prefix) must fit in <code>isize</code>.</li>
<li>a <a href="../../book/ch17-02-trait-objects.html">trait object</a>, then the vtable part of the pointer must point
to a valid vtable for the type <code>T</code> acquired by an unsizing coercion,
and the size of the <em>entire value</em>
(dynamic tail length + statically sized prefix) must fit in <code>isize</code>.</li>
<li>an (unstable) <a href="../../unstable-book/language-features/extern-types.html">extern type</a>, then this function is always safe to
call, but may panic or otherwise return the wrong value, as the
extern types layout is not known. This is the same behavior as
<a href="struct.Layout.html#method.for_value" title="associated function allocator_api2::alloc::Layout::for_value"><code>Layout::for_value</code></a> on a reference to an extern type tail.</li>
<li>otherwise, it is conservatively not allowed to call this function.</li>
</ul>
</li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="method.dangling" class="method"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/55724" title="Tracking issue for alloc_layout_extra">unstable</a></span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#216">source</a></span><h4 class="code-header">pub fn <a href="#method.dangling" class="fn">dangling</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/ptr/non_null/struct.NonNull.html" title="struct core::ptr::non_null::NonNull">NonNull</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.u8.html">u8</a>&gt;</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>alloc_layout_extra</code>)</span></div></span></summary><div class="docblock"><p>Creates a <code>NonNull</code> that is dangling, but well-aligned for this Layout.</p>
<p>Note that the pointer value may potentially represent a valid pointer,
which means this must not be used as a “not yet initialized”
sentinel value. Types that lazily allocate must track initialization by
some other means.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.align_to" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.44.0">1.44.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#237">source</a></span><h4 class="code-header">pub fn <a href="#method.align_to" class="fn">align_to</a>(&amp;self, align: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>, <a class="struct" href="struct.LayoutError.html" title="struct allocator_api2::alloc::LayoutError">LayoutError</a>&gt;</h4></section></summary><div class="docblock"><p>Creates a layout describing the record that can hold a value
of the same layout as <code>self</code>, but that also is aligned to
alignment <code>align</code> (measured in bytes).</p>
<p>If <code>self</code> already meets the prescribed alignment, then returns
<code>self</code>.</p>
<p>Note that this method does not add any padding to the overall
size, regardless of whether the returned layout has a different
alignment. In other words, if <code>K</code> has size 16, <code>K.align_to(32)</code>
will <em>still</em> have size 16.</p>
<p>Returns an error if the combination of <code>self.size()</code> and the given
<code>align</code> violates the conditions listed in <a href="struct.Layout.html#method.from_size_align" title="associated function allocator_api2::alloc::Layout::from_size_align"><code>Layout::from_size_align</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.padding_needed_for" class="method"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/67521" title="Tracking issue for const_alloc_layout">unstable</a></span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#262">source</a></span><h4 class="code-header">pub fn <a href="#method.padding_needed_for" class="fn">padding_needed_for</a>(&amp;self, align: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>alloc_layout_extra</code>)</span></div></span></summary><div class="docblock"><p>Returns the amount of padding we must insert after <code>self</code>
to ensure that the following address will satisfy <code>align</code>
(measured in bytes).</p>
<p>e.g., if <code>self.size()</code> is 9, then <code>self.padding_needed_for(4)</code>
returns 3, because that is the minimum number of bytes of
padding required to get a 4-aligned address (assuming that the
corresponding memory block starts at a 4-aligned address).</p>
<p>The return value of this function has no meaning if <code>align</code> is
not a power-of-two.</p>
<p>Note that the utility of the returned value requires <code>align</code>
to be less than or equal to the alignment of the starting
address for the whole allocated block of memory. One way to
satisfy this constraint is to ensure <code>align &lt;= self.align()</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.pad_to_align" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.44.0, const unstable">1.44.0 (const: <a href="https://github.com/rust-lang/rust/issues/67521" title="Tracking issue for const_alloc_layout">unstable</a>)</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#298">source</a></span><h4 class="code-header">pub fn <a href="#method.pad_to_align" class="fn">pad_to_align</a>(&amp;self) -&gt; <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h4></section></summary><div class="docblock"><p>Creates a layout by rounding the size of this layout up to a multiple
of the layouts alignment.</p>
<p>This is equivalent to adding the result of <code>padding_needed_for</code>
to the layouts current size.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.repeat" class="method"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#320">source</a><h4 class="code-header">pub fn <a href="#method.repeat" class="fn">repeat</a>(&amp;self, n: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(<a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>, <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>), <a class="struct" href="struct.LayoutError.html" title="struct allocator_api2::alloc::LayoutError">LayoutError</a>&gt;</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>alloc_layout_extra</code>)</span></div></span></summary><div class="docblock"><p>Creates a layout describing the record for <code>n</code> instances of
<code>self</code>, with a suitable amount of padding between each to
ensure that each instance is given its requested size and
alignment. On success, returns <code>(k, offs)</code> where <code>k</code> is the
layout of the array and <code>offs</code> is the distance between the start
of each element in the array.</p>
<p>On arithmetic overflow, returns <code>LayoutError</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.extend" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.44.0">1.44.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#380">source</a></span><h4 class="code-header">pub fn <a href="#method.extend" class="fn">extend</a>(&amp;self, next: <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(<a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>, <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>), <a class="struct" href="struct.LayoutError.html" title="struct allocator_api2::alloc::LayoutError">LayoutError</a>&gt;</h4></section></summary><div class="docblock"><p>Creates a layout describing the record for <code>self</code> followed by
<code>next</code>, including any necessary padding to ensure that <code>next</code>
will be properly aligned, but <em>no trailing padding</em>.</p>
<p>In order to match C representation layout <code>repr(C)</code>, you should
call <code>pad_to_align</code> after extending the layout with all fields.
(There is no way to match the default Rust representation
layout <code>repr(Rust)</code>, as it is unspecified.)</p>
<p>Note that the alignment of the resulting layout will be the maximum of
those of <code>self</code> and <code>next</code>, in order to ensure alignment of both parts.</p>
<p>Returns <code>Ok((k, offset))</code>, where <code>k</code> is layout of the concatenated
record and <code>offset</code> is the relative location, in bytes, of the
start of the <code>next</code> embedded within the concatenated record
(assuming that the record itself starts at offset 0).</p>
<p>On arithmetic overflow, returns <code>LayoutError</code>.</p>
<h5 id="examples"><a href="#examples">Examples</a></h5>
<p>To calculate the layout of a <code>#[repr(C)]</code> structure and the offsets of
the fields from its fields layouts:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">pub fn </span>repr_c(fields: <span class="kw-2">&amp;</span>[Layout]) -&gt; <span class="prelude-ty">Result</span>&lt;(Layout, Vec&lt;usize&gt;), LayoutError&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>offsets = Vec::new();
<span class="kw">let </span><span class="kw-2">mut </span>layout = Layout::from_size_align(<span class="number">0</span>, <span class="number">1</span>)<span class="question-mark">?</span>;
<span class="kw">for </span><span class="kw-2">&amp;</span>field <span class="kw">in </span>fields {
<span class="kw">let </span>(new_layout, offset) = layout.extend(field)<span class="question-mark">?</span>;
layout = new_layout;
offsets.push(offset);
}
<span class="comment">// Remember to finalize with `pad_to_align`!
</span><span class="prelude-val">Ok</span>((layout.pad_to_align(), offsets))
}</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.repeat_packed" class="method"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#406">source</a><h4 class="code-header">pub fn <a href="#method.repeat_packed" class="fn">repeat_packed</a>(&amp;self, n: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>, <a class="struct" href="struct.LayoutError.html" title="struct allocator_api2::alloc::LayoutError">LayoutError</a>&gt;</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>alloc_layout_extra</code>)</span></div></span></summary><div class="docblock"><p>Creates a layout describing the record for <code>n</code> instances of
<code>self</code>, with no padding between each instance.</p>
<p>Note that, unlike <code>repeat</code>, <code>repeat_packed</code> does not guarantee
that the repeated instances of <code>self</code> will be properly
aligned, even if a given instance of <code>self</code> is properly
aligned. In other words, if the layout returned by
<code>repeat_packed</code> is used to allocate an array, it is not
guaranteed that all elements in the array will be properly
aligned.</p>
<p>On arithmetic overflow, returns <code>LayoutError</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.extend_packed" class="method"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#420">source</a><h4 class="code-header">pub fn <a href="#method.extend_packed" class="fn">extend_packed</a>(&amp;self, next: <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>, <a class="struct" href="struct.LayoutError.html" title="struct allocator_api2::alloc::LayoutError">LayoutError</a>&gt;</h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>alloc_layout_extra</code>)</span></div></span></summary><div class="docblock"><p>Creates a layout describing the record for <code>self</code> followed by
<code>next</code> with no additional padding between the two. Since no
padding is inserted, the alignment of <code>next</code> is irrelevant,
and is not incorporated <em>at all</em> into the resulting layout.</p>
<p>On arithmetic overflow, returns <code>LayoutError</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.array" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.44.0, const unstable">1.44.0 (const: <a href="https://github.com/rust-lang/rust/issues/67521" title="Tracking issue for const_alloc_layout">unstable</a>)</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#433">source</a></span><h4 class="code-header">pub fn <a href="#method.array" class="fn">array</a>&lt;T&gt;(n: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.usize.html">usize</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>, <a class="struct" href="struct.LayoutError.html" title="struct allocator_api2::alloc::LayoutError">LayoutError</a>&gt;</h4></section></summary><div class="docblock"><p>Creates a layout describing the record for a <code>[T; n]</code>.</p>
<p>On arithmetic overflow or when the total size would exceed
<code>isize::MAX</code>, returns <code>LayoutError</code>.</p>
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Clone-for-Layout" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#impl-Clone-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&amp;self) -&gt; <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/clone.rs.html#169">source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;Self</a>)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Layout" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#impl-Debug-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Hash-for-Layout" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#impl-Hash-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#method.hash" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/hash/trait.Hash.html#tymethod.hash" class="fn">hash</a>&lt;__H&gt;(&amp;self, state: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut __H</a>)<div class="where">where
__H: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,</div></h4></section></summary><div class='docblock'>Feeds this value into the given <a href="https://doc.rust-lang.org/1.76.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.76.0/core/hash/trait.Hash.html#tymethod.hash">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/hash/mod.rs.html#238-240">source</a></span><a href="#method.hash_slice" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/hash/trait.Hash.html#method.hash_slice" class="fn">hash_slice</a>&lt;H&gt;(data: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.slice.html">[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut H</a>)<div class="where">where
H: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,
Self: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/1.76.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.76.0/core/hash/trait.Hash.html#method.hash_slice">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq-for-Layout" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#impl-PartialEq-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&amp;self, other: &amp;<a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.76.0/src/core/cmp.rs.html#242">source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always
sufficient, and should not be overridden without very good reason.</div></details></div></details><section id="impl-Copy-for-Layout" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#impl-Copy-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section><section id="impl-Eq-for-Layout" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#impl-Eq-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section><section id="impl-StructuralEq-for-Layout" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#impl-StructuralEq-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.StructuralEq.html" title="trait core::marker::StructuralEq">StructuralEq</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section><section id="impl-StructuralPartialEq-for-Layout" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/alloc/layout.rs.html#36">source</a><a href="#impl-StructuralPartialEq-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-Layout" class="impl"><a href="#impl-RefUnwindSafe-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section><section id="impl-Send-for-Layout" class="impl"><a href="#impl-Send-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section><section id="impl-Sync-for-Layout" class="impl"><a href="#impl-Sync-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section><section id="impl-Unpin-for-Layout" class="impl"><a href="#impl-Unpin-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section><section id="impl-UnwindSafe-for-Layout" class="impl"><a href="#impl-UnwindSafe-for-Layout" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Layout.html" title="struct allocator_api2::alloc::Layout">Layout</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.76.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.76.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.76.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.76.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#763">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#766">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#747-749">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#756">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToOwned-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#83-85">source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl"><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#88">source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&amp;self) -&gt; T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/alloc/borrow.rs.html#92">source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&amp;self, target: <a class="primitive" href="https://doc.rust-lang.org/1.76.0/core/primitive.reference.html">&amp;mut T</a>)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.76.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#803-805">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#810">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#788-790">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.76.0/src/core/convert/mod.rs.html#795">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.76.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.76.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>