Adding large folders

This commit is contained in:
2026-02-26 12:00:21 -05:00
parent 5400d82acd
commit 49701c85ad
47332 changed files with 1942573 additions and 0 deletions

View File

@@ -0,0 +1 @@
<!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="List of all items in this crate"><title>List of all items in this crate</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"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="stable_deref_trait" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">All</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../stable_deref_trait/index.html">stable_<wbr>deref_<wbr>trait</a><span class="version">1.2.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h3><a href="#traits">Crate Items</a></h3><ul class="block"><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>List of all items</h1><rustdoc-toolbar></rustdoc-toolbar></div><h3 id="traits">Traits</h3><ul class="all-items"><li><a href="trait.CloneStableDeref.html">CloneStableDeref</a></li><li><a href="trait.StableDeref.html">StableDeref</a></li></ul></section></div></main></body></html>

View File

@@ -0,0 +1,4 @@
<!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="This module defines an unsafe marker trait, StableDeref, for container types that deref to a fixed address which is valid even when the containing type is moved. For example, Box, Vec, Rc, Arc and String implement this trait. Additionally, it defines CloneStableDeref for types like Rc where clones deref to the same address."><title>stable_deref_trait - 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"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="stable_deref_trait" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Crate stable_deref_trait</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../stable_deref_trait/index.html">stable_<wbr>deref_<wbr>trait</a><span class="version">1.2.1</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#traits">Crate Items</a></h3><ul class="block"><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>stable_<wbr>deref_<wbr>trait</span>&nbsp;<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="../src/stable_deref_trait/lib.rs.html#9-202">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This module defines an unsafe marker trait, StableDeref, for container types that deref to a fixed address which is valid even when the containing type is moved. For example, Box, Vec, Rc, Arc and String implement this trait. Additionally, it defines CloneStableDeref for types like Rc where clones deref to the same address.</p>
<p>It is intended to be used by crates such as <a href="https://crates.io/crates/owning_ref">owning_ref</a> and <a href="https://crates.io/crates/rental">rental</a>, as well as library authors who wish to make their code interoperable with such crates. For example, if you write a custom Vec type, you can implement StableDeref, and then users will be able to use your custom type together with owning_ref and rental.</p>
<p>no_std support can be enabled by disabling default features (specifically “std”). In this case, the trait will not be implemented for the std types mentioned above, but you can still use it for your own types.</p>
</div></details><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.CloneStableDeref.html" title="trait stable_deref_trait::CloneStableDeref">Clone<wbr>Stable<wbr>Deref</a></dt><dd>An unsafe marker trait for types where clones deref to the same address. This has all the requirements of StableDeref, and additionally requires that after calling clone(), both the old and new value deref to the same address. For example, Rc and Arc implement CloneStableDeref, but Box and Vec do not.</dd><dt><a class="trait" href="trait.StableDeref.html" title="trait stable_deref_trait::StableDeref">Stable<wbr>Deref</a></dt><dd>An unsafe marker trait for types that deref to a stable address, even when moved. For example, this is implemented by Box, Vec, Rc, Arc and String, among others. Even when a Box is moved, the underlying storage remains at a fixed location.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"trait":["CloneStableDeref","StableDeref"]};

View File

@@ -0,0 +1,3 @@
<!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="An unsafe marker trait for types where clones deref to the same address. This has all the requirements of StableDeref, and additionally requires that after calling clone(), both the old and new value deref to the same address. For example, Rc and Arc implement CloneStableDeref, but Box and Vec do not."><title>CloneStableDeref in stable_deref_trait - 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"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="stable_deref_trait" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.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]--><rustdoc-topbar><h2><a href="#">CloneStableDeref</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../stable_deref_trait/index.html">stable_<wbr>deref_<wbr>trait</a><span class="version">1.2.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Clone<wbr>Stable<wbr>Deref</a></h2><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-CloneStableDeref-for-%26T" title="&#38;&#39;a T">&#38;&#39;a T</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate stable_<wbr>deref_<wbr>trait</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">stable_deref_trait</a></div><h1>Trait <span class="trait">Clone<wbr>Stable<wbr>Deref</span>&nbsp;<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="../src/stable_deref_trait/lib.rs.html#129">Source</a> </span></div><pre class="rust item-decl"><code>pub unsafe trait CloneStableDeref: <a class="trait" href="trait.StableDeref.html" title="trait stable_deref_trait::StableDeref">StableDeref</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> { }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An unsafe marker trait for types where clones deref to the same address. This has all the requirements of StableDeref, and additionally requires that after calling clone(), both the old and new value deref to the same address. For example, Rc and Arc implement CloneStableDeref, but Box and Vec do not.</p>
<p>Note that a single type should never implement both DerefMut and CloneStableDeref. If it did, this would let you get two mutable references to the same location, by cloning and then calling deref_mut() on both values.</p>
</div></details><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><section id="impl-CloneStableDeref-for-%26T" class="impl"><a class="src rightside" href="../src/stable_deref_trait/lib.rs.html#201">Source</a><a href="#impl-CloneStableDeref-for-%26T" class="anchor">§</a><h3 class="code-header">impl&lt;'a, T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="trait.CloneStableDeref.html" title="trait stable_deref_trait::CloneStableDeref">CloneStableDeref</a> for <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.reference.html">&amp;'a T</a></h3></section><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../trait.impl/stable_deref_trait/trait.CloneStableDeref.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,59 @@
<!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="An unsafe marker trait for types that deref to a stable address, even when moved. For example, this is implemented by Box, Vec, Rc, Arc and String, among others. Even when a Box is moved, the underlying storage remains at a fixed location."><title>StableDeref in stable_deref_trait - 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"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="stable_deref_trait" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.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]--><rustdoc-topbar><h2><a href="#">StableDeref</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../stable_deref_trait/index.html">stable_<wbr>deref_<wbr>trait</a><span class="version">1.2.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Stable<wbr>Deref</a></h2><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-StableDeref-for-%26T" title="&#38;&#39;a T">&#38;&#39;a T</a></li><li><a href="#impl-StableDeref-for-%26mut+T" title="&#38;&#39;a mut T">&#38;&#39;a mut T</a></li><li><a href="#impl-StableDeref-for-Ref%3C'a,+T%3E" title="Ref&#60;&#39;a, T&#62;">Ref&#60;&#39;a, T&#62;</a></li><li><a href="#impl-StableDeref-for-RefMut%3C'a,+T%3E" title="RefMut&#60;&#39;a, T&#62;">RefMut&#60;&#39;a, T&#62;</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate stable_<wbr>deref_<wbr>trait</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">stable_deref_trait</a></div><h1>Trait <span class="trait">Stable<wbr>Deref</span>&nbsp;<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="../src/stable_deref_trait/lib.rs.html#122">Source</a> </span></div><pre class="rust item-decl"><code>pub unsafe trait StableDeref: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> { }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An unsafe marker trait for types that deref to a stable address, even when moved. For example, this is implemented by Box, Vec, Rc, Arc and String, among others. Even when a Box is moved, the underlying storage remains at a fixed location.</p>
<p>More specifically, implementors must ensure that the result of calling deref() is valid for the lifetime of the object, not just the lifetime of the borrow, and that the deref is valid even if the object is moved. Also, it must be valid even after invoking arbitrary &amp;self methods or doing anything transitively accessible from &amp;Self. If Self also implements DerefMut, the same restrictions apply to deref_mut() and it must remain valid if anything transitively accessible from the result of deref_mut() is mutated/called. Additionally, multiple calls to deref, (and deref_mut if implemented) must return the same address. No requirements are placed on &amp;mut self methods other than deref_mut() and drop(), if applicable.</p>
<p>Basically, it must be valid to convert the result of deref() to a pointer, and later dereference that pointer, as long as the original object is still live, even if it has been moved or &amp;self methods have been called on it. If DerefMut is also implemented, it must be valid to get pointers from deref() and deref_mut() and dereference them while the object is live, as long as you dont simultaneously dereference both of them.</p>
<p>Additionally, Deref and DerefMut implementations must not panic, but users of the trait are not allowed to rely on this fact (so that this restriction can be removed later without breaking backwards compatibility, should the need arise).</p>
<p>Here are some examples to help illustrate the requirements for implementing this trait:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>Foo(u8);
<span class="kw">impl </span>Deref <span class="kw">for </span>Foo {
<span class="kw">type </span>Target = u8;
<span class="kw">fn </span>deref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="self">Self</span>::Target { <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0 </span>}
}</code></pre></div>
<p>Foo cannot implement StableDeref because the int will move when Foo is moved, invalidating the result of deref().</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>Foo(Box&lt;u8&gt;);
<span class="kw">impl </span>Deref <span class="kw">for </span>Foo {
<span class="kw">type </span>Target = u8;
<span class="kw">fn </span>deref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="self">Self</span>::Target { <span class="kw-2">&amp;*</span><span class="self">self</span>.<span class="number">0 </span>}
}</code></pre></div>
<p>Foo can safely implement StableDeref, due to the use of Box.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[derive(Clone)]
</span><span class="kw">struct </span>Foo(Rc&lt;u8&gt;);
<span class="kw">impl </span>Deref <span class="kw">for </span>Foo {
<span class="kw">type </span>Target = u8;
<span class="kw">fn </span>deref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="self">Self</span>::Target { <span class="kw-2">&amp;*</span><span class="self">self</span>.<span class="number">0 </span>}
}
<span class="kw">impl </span>DerefMut <span class="kw">for </span>Foo {
<span class="kw">fn </span>deref_mut(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut </span><span class="self">Self</span>::Target { Rc::make_mut(<span class="kw-2">&amp;mut </span><span class="self">self</span>.<span class="number">0</span>) }
}</code></pre></div>
<p>This is a simple implementation of copy-on-write: Foos deref_mut will copy the underlying int if it is not uniquely owned, ensuring unique access at the point where deref_mut() returns. However, Foo cannot implement StableDeref because calling deref_mut(), followed by clone().deref() will result in mutable and immutable references to the same location. Note that if the DerefMut implementation were removed, Foo could safely implement StableDeref. Likewise, if the Clone implementation were removed, it would be safe to implement StableDeref, although Foo would not be very useful in that case, (without clones, the rc will always be uniquely owned).</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>Foo;
<span class="kw">impl </span>Deref <span class="kw">for </span>Foo {
<span class="kw">type </span>Target = str;
<span class="kw">fn </span>deref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="self">Self</span>::Target { <span class="kw-2">&amp;</span><span class="string">"Hello" </span>}
}</code></pre></div>
<p>Foo can safely implement StableDeref. It doesnt own the data being derefed, but the data is gaurenteed to live long enough, due to it being static.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>Foo(Cell&lt;bool&gt;);
<span class="kw">impl </span>Deref <span class="kw">for </span>Foo {
<span class="kw">type </span>Target = str;
<span class="kw">fn </span>deref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="self">Self</span>::Target {
<span class="kw">let </span>b = <span class="self">self</span>.<span class="number">0</span>.get();
<span class="self">self</span>.<span class="number">0</span>.set(!b);
<span class="kw">if </span>b { <span class="kw-2">&amp;</span><span class="string">"Hello" </span>} <span class="kw">else </span>{ <span class="kw-2">&amp;</span><span class="string">"World" </span>}
}
}</code></pre></div>
<p>Foo cannot safely implement StableDeref, even though every possible result of deref lives long enough. In order to safely implement StableAddress, multiple calls to deref must return the same result.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">struct </span>Foo(Box&lt;(u8, u8)&gt;);
<span class="kw">impl </span>Deref <span class="kw">for </span>Foo {
<span class="kw">type </span>Target = u8;
<span class="kw">fn </span>deref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span><span class="self">Self</span>::Target { <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>.deref().<span class="number">0 </span>}
}
<span class="kw">impl </span>DerefMut <span class="kw">for </span>Foo {
<span class="kw">fn </span>deref_mut(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;mut </span><span class="self">Self</span>::Target { <span class="kw-2">&amp;mut </span><span class="self">self</span>.<span class="number">0</span>.deref_mut().<span class="number">1 </span>}
}</code></pre></div>
<p>Foo cannot implement StableDeref because deref and deref_mut return different addresses.</p>
</div></details><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><section id="impl-StableDeref-for-%26T" class="impl"><a class="src rightside" href="../src/stable_deref_trait/lib.rs.html#200">Source</a><a href="#impl-StableDeref-for-%26T" class="anchor">§</a><h3 class="code-header">impl&lt;'a, T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="trait.StableDeref.html" title="trait stable_deref_trait::StableDeref">StableDeref</a> for <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.reference.html">&amp;'a T</a></h3></section><section id="impl-StableDeref-for-%26mut+T" class="impl"><a class="src rightside" href="../src/stable_deref_trait/lib.rs.html#202">Source</a><a href="#impl-StableDeref-for-%26mut+T" class="anchor">§</a><h3 class="code-header">impl&lt;'a, T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="trait.StableDeref.html" title="trait stable_deref_trait::StableDeref">StableDeref</a> for <a class="primitive" href="https://doc.rust-lang.org/1.93.1/core/primitive.reference.html">&amp;'a mut T</a></h3></section><section id="impl-StableDeref-for-Ref%3C'a,+T%3E" class="impl"><a class="src rightside" href="../src/stable_deref_trait/lib.rs.html#191">Source</a><a href="#impl-StableDeref-for-Ref%3C'a,+T%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="trait.StableDeref.html" title="trait stable_deref_trait::StableDeref">StableDeref</a> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/cell/struct.Ref.html" title="struct core::cell::Ref">Ref</a>&lt;'a, T&gt;</h3></section><section id="impl-StableDeref-for-RefMut%3C'a,+T%3E" class="impl"><a class="src rightside" href="../src/stable_deref_trait/lib.rs.html#192">Source</a><a href="#impl-StableDeref-for-RefMut%3C'a,+T%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'a, T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="trait" href="trait.StableDeref.html" title="trait stable_deref_trait::StableDeref">StableDeref</a> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/cell/struct.RefMut.html" title="struct core::cell::RefMut">RefMut</a>&lt;'a, T&gt;</h3></section><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../trait.impl/stable_deref_trait/trait.StableDeref.js" data-ignore-extern-crates="core" async></script></section></div></main></body></html>