<!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="API documentation for the Rust `Weak` struct in crate `std`."><meta name="keywords" content="rust, rustlang, rust-lang, Weak"><title>std::rc::Weak - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize1.35.0.css"><link rel="stylesheet" type="text/css" href="../../rustdoc1.35.0.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../dark1.35.0.css"><link rel="stylesheet" type="text/css" href="../../light1.35.0.css" id="themeStyle"><script src="../../storage1.35.0.js"></script><noscript><link rel="stylesheet" href="../../noscript1.35.0.css"></noscript><link rel="shortcut icon" href="../../favicon1.35.0.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow1.35.0.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../../std/index.html'><img src='../../rust-logo1.35.0.png' alt='logo' width='100'></a><p class='location'>Struct Weak</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.new">new</a><a href="#method.ptr_eq">ptr_eq</a><a href="#method.strong_count">strong_count</a><a href="#method.upgrade">upgrade</a><a href="#method.weak_count">weak_count</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Clone">Clone</a><a href="#impl-CoerceUnsized%3CWeak%3CU%3E%3E">CoerceUnsized<Weak<U>></a><a href="#impl-Debug">Debug</a><a href="#impl-Default">Default</a><a href="#impl-DispatchFromDyn%3CWeak%3CU%3E%3E">DispatchFromDyn<Weak<U>></a><a href="#impl-Drop">Drop</a><a href="#impl-Send">!Send</a><a href="#impl-Sync">!Sync</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow">Borrow</a><a href="#impl-BorrowMut">BorrowMut</a><a href="#impl-From">From</a><a href="#impl-Into">Into</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-TryFrom">TryFrom</a><a href="#impl-TryInto">TryInto</a></div></div><p class='location'><a href='../index.html'>std</a>::<wbr><a href='index.html'>rc</a></p><script>window.sidebarCurrent = {name: 'Weak', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../../brush1.35.0.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../../theme1.35.0.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../../settings.html"><img src="../../wheel1.35.0.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span class='since' title='Stable since Rust version 1.4.0'>1.4.0</span><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../src/alloc/rc.rs.html#1219-1226' title='goto source code'>[src]</a></span><span class='in-band'>Struct <a href='../index.html'>std</a>::<wbr><a href='index.html'>rc</a>::<wbr><a class="struct" href=''>Weak</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust struct'>pub struct Weak<T> <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span> { /* fields omitted */ }</pre></div><div class='docblock'><p><code>Weak</code> is a version of <a href="struct.Rc.html"><code>Rc</code></a> that holds a non-owning reference to the managed value. The value is accessed by calling <a href="struct.Weak.html#method.upgrade"><code>upgrade</code></a> on the <code>Weak</code> pointer, which returns an <a href="../../std/option/enum.Option.html"><code>Option</code></a><code><</code><a href="struct.Rc.html"><code>Rc</code></a><code><T>></code>.</p> <p>Since a <code>Weak</code> reference does not count towards ownership, it will not prevent the inner value from being dropped, and <code>Weak</code> itself makes no guarantees about the value still being present and may return <a href="../../std/option/enum.Option.html#variant.None"><code>None</code></a> when <a href="struct.Weak.html#method.upgrade"><code>upgrade</code></a>d.</p> <p>A <code>Weak</code> pointer is useful for keeping a temporary reference to the value within <a href="struct.Rc.html"><code>Rc</code></a> without extending its lifetime. It is also used to prevent circular references between <a href="struct.Rc.html"><code>Rc</code></a> pointers, since mutual owning references would never allow either <a href="struct.Rc.html"><code>Rc</code></a> to be dropped. For example, a tree could have strong <a href="struct.Rc.html"><code>Rc</code></a> pointers from parent nodes to children, and <code>Weak</code> pointers from children back to their parents.</p> <p>The typical way to obtain a <code>Weak</code> pointer is to call <a href="struct.Rc.html#method.downgrade"><code>Rc::downgrade</code></a>.</p> </div><h2 id='methods' class='small-section-header'>Methods<a href='#methods' class='anchor'></a></h2><h3 id='impl' class='impl'><code class='in-band'>impl<T> <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T></code><a href='#impl' class='anchor'></a><a class='srclink' href='../../src/alloc/rc.rs.html#1239-1260' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.new' class="method"><code id='new.v'>pub fn <a href='#method.new' class='fnname'>new</a>() -> <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T></code><div class='since' title='Stable since Rust version 1.10.0'>1.10.0</div><a class='srclink' href='../../src/alloc/rc.rs.html#1255-1259' title='goto source code'>[src]</a></h4><div class='docblock'><p>Constructs a new <code>Weak<T></code>, without allocating any memory. Calling <a href="#method.upgrade"><code>upgrade</code></a> on the return value always gives <a href="../../std/option/enum.Option.html"><code>None</code></a>.</p> <h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::<span class="ident">Weak</span>; <span class="kw">let</span> <span class="ident">empty</span>: <span class="ident">Weak</span><span class="op"><</span><span class="ident">i64</span><span class="op">></span> <span class="op">=</span> <span class="ident">Weak</span>::<span class="ident">new</span>(); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">empty</span>.<span class="ident">upgrade</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Arc%3A%3AWeak%3B%0A%0Alet%20empty%3A%20Weak%3Ci64%3E%20%3D%20Weak%3A%3Anew()%3B%0Aassert!(empty.upgrade().is_none())%3B%0A%7D">Run</a></pre></div> </div></div><h3 id='impl-1' class='impl'><code class='in-band'>impl<T> <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T> <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-1' class='anchor'></a><a class='srclink' href='../../src/alloc/rc.rs.html#1267-1393' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.upgrade' class="method"><code id='upgrade.v'>pub fn <a href='#method.upgrade' class='fnname'>upgrade</a>(&self) -> <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a><<a class="struct" href="../../std/rc/struct.Rc.html" title="struct std::rc::Rc">Rc</a><T>></code><a class='srclink' href='../../src/alloc/rc.rs.html#1295-1303' title='goto source code'>[src]</a></h4><div class='docblock'><p>Attempts to upgrade the <code>Weak</code> pointer to an <a href="struct.Rc.html"><code>Rc</code></a>, extending the lifetime of the value if successful.</p> <p>Returns <a href="../../std/option/enum.Option.html"><code>None</code></a> if the value has since been dropped.</p> <h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::<span class="ident">Rc</span>; <span class="kw">let</span> <span class="ident">five</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="number">5</span>); <span class="kw">let</span> <span class="ident">weak_five</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&</span><span class="ident">five</span>); <span class="kw">let</span> <span class="ident">strong_five</span>: <span class="prelude-ty">Option</span><span class="op"><</span><span class="ident">Rc</span><span class="op"><</span><span class="kw">_</span><span class="op">>></span> <span class="op">=</span> <span class="ident">weak_five</span>.<span class="ident">upgrade</span>(); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">strong_five</span>.<span class="ident">is_some</span>()); <span class="comment">// Destroy all strong pointers.</span> <span class="ident">drop</span>(<span class="ident">strong_five</span>); <span class="ident">drop</span>(<span class="ident">five</span>); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">weak_five</span>.<span class="ident">upgrade</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Arc%3A%3ARc%3B%0A%0Alet%20five%20%3D%20Rc%3A%3Anew(5)%3B%0A%0Alet%20weak_five%20%3D%20Rc%3A%3Adowngrade(%26five)%3B%0A%0Alet%20strong_five%3A%20Option%3CRc%3C_%3E%3E%20%3D%20weak_five.upgrade()%3B%0Aassert!(strong_five.is_some())%3B%0A%0A%2F%2F%20Destroy%20all%20strong%20pointers.%0Adrop(strong_five)%3B%0Adrop(five)%3B%0A%0Aassert!(weak_five.upgrade().is_none())%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.strong_count' class="method"><code id='strong_count.v'>pub fn <a href='#method.strong_count' class='fnname'>strong_count</a>(&self) -> <a class="primitive" href="../primitive.usize.html">usize</a></code><a class='srclink' href='../../src/alloc/rc.rs.html#1311-1317' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>weak_counts</code> <a href="https://github.com/rust-lang/rust/issues/57977">#57977</a>)</div></div><div class='docblock'><p>Gets the number of strong (<code>Rc</code>) pointers pointing to this value.</p> <p>If <code>self</code> was created using <a href="#method.new"><code>Weak::new</code></a>, this will return 0.</p> </div><h4 id='method.weak_count' class="method"><code id='weak_count.v'>pub fn <a href='#method.weak_count' class='fnname'>weak_count</a>(&self) -> <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code><a class='srclink' href='../../src/alloc/rc.rs.html#1327-1335' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>weak_counts</code> <a href="https://github.com/rust-lang/rust/issues/57977">#57977</a>)</div></div><div class='docblock'><p>Gets the number of <code>Weak</code> pointers pointing to this value.</p> <p>If <code>self</code> was created using <a href="#method.new"><code>Weak::new</code></a>, this will return <code>None</code>. If not, the returned value is at least 1, since <code>self</code> still points to the value.</p> </div><h4 id='method.ptr_eq' class="method"><code id='ptr_eq.v'>pub fn <a href='#method.ptr_eq' class='fnname'>ptr_eq</a>(this: &<a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T>, other: &<a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T>) -> <a class="primitive" href="../primitive.bool.html">bool</a></code><a class='srclink' href='../../src/alloc/rc.rs.html#1390-1392' title='goto source code'>[src]</a></h4><div class='stability'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>weak_ptr_eq</code> <a href="https://github.com/rust-lang/rust/issues/55981">#55981</a>)</div></div><div class='docblock'><p>Returns <code>true</code> if the two <code>Weak</code>s point to the same value (not just values that compare as equal).</p> <h1 id="notes" class="section-header"><a href="#notes">Notes</a></h1> <p>Since this compares pointers it means that <code>Weak::new()</code> will equal each other, even though they don't point to any value.</p> <h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="attribute">#![<span class="ident">feature</span>(<span class="ident">weak_ptr_eq</span>)]</span> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::{<span class="ident">Rc</span>, <span class="ident">Weak</span>}; <span class="kw">let</span> <span class="ident">first_rc</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="number">5</span>); <span class="kw">let</span> <span class="ident">first</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&</span><span class="ident">first_rc</span>); <span class="kw">let</span> <span class="ident">second</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&</span><span class="ident">first_rc</span>); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Weak</span>::<span class="ident">ptr_eq</span>(<span class="kw-2">&</span><span class="ident">first</span>, <span class="kw-2">&</span><span class="ident">second</span>)); <span class="kw">let</span> <span class="ident">third_rc</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="number">5</span>); <span class="kw">let</span> <span class="ident">third</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&</span><span class="ident">third_rc</span>); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Weak</span>::<span class="ident">ptr_eq</span>(<span class="kw-2">&</span><span class="ident">first</span>, <span class="kw-2">&</span><span class="ident">third</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(weak_ptr_eq)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Arc%3A%3A%7BRc%2C%20Weak%7D%3B%0A%0Alet%20first_rc%20%3D%20Rc%3A%3Anew(5)%3B%0Alet%20first%20%3D%20Rc%3A%3Adowngrade(%26first_rc)%3B%0Alet%20second%20%3D%20Rc%3A%3Adowngrade(%26first_rc)%3B%0A%0Aassert!(Weak%3A%3Aptr_eq(%26first%2C%20%26second))%3B%0A%0Alet%20third_rc%20%3D%20Rc%3A%3Anew(5)%3B%0Alet%20third%20%3D%20Rc%3A%3Adowngrade(%26third_rc)%3B%0A%0Aassert!(!Weak%3A%3Aptr_eq(%26first%2C%20%26third))%3B%0A%7D&version=nightly">Run</a></pre></div> <p>Comparing <code>Weak::new</code>.</p> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="attribute">#![<span class="ident">feature</span>(<span class="ident">weak_ptr_eq</span>)]</span> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::{<span class="ident">Rc</span>, <span class="ident">Weak</span>}; <span class="kw">let</span> <span class="ident">first</span> <span class="op">=</span> <span class="ident">Weak</span>::<span class="ident">new</span>(); <span class="kw">let</span> <span class="ident">second</span> <span class="op">=</span> <span class="ident">Weak</span>::<span class="ident">new</span>(); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">Weak</span>::<span class="ident">ptr_eq</span>(<span class="kw-2">&</span><span class="ident">first</span>, <span class="kw-2">&</span><span class="ident">second</span>)); <span class="kw">let</span> <span class="ident">third_rc</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">new</span>(()); <span class="kw">let</span> <span class="ident">third</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&</span><span class="ident">third_rc</span>); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">Weak</span>::<span class="ident">ptr_eq</span>(<span class="kw-2">&</span><span class="ident">first</span>, <span class="kw-2">&</span><span class="ident">third</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(weak_ptr_eq)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Arc%3A%3A%7BRc%2C%20Weak%7D%3B%0A%0Alet%20first%20%3D%20Weak%3A%3Anew()%3B%0Alet%20second%20%3D%20Weak%3A%3Anew()%3B%0Aassert!(Weak%3A%3Aptr_eq(%26first%2C%20%26second))%3B%0A%0Alet%20third_rc%20%3D%20Rc%3A%3Anew(())%3B%0Alet%20third%20%3D%20Rc%3A%3Adowngrade(%26third_rc)%3B%0Aassert!(!Weak%3A%3Aptr_eq(%26first%2C%20%26third))%3B%0A%7D&version=nightly">Run</a></pre></div> </div></div><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-Clone' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/clone/trait.Clone.html" title="trait std::clone::Clone">Clone</a> for <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T> <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-Clone' class='anchor'></a><a class='srclink' href='../../src/alloc/rc.rs.html#1436-1455' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.clone' class="method"><code id='clone.v'>fn <a href='../../std/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&self) -> <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T></code><a class='srclink' href='../../src/alloc/rc.rs.html#1449-1454' title='goto source code'>[src]</a></h4><div class='docblock'><p>Makes a clone of the <code>Weak</code> pointer that points to the same value.</p> <h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::{<span class="ident">Rc</span>, <span class="ident">Weak</span>}; <span class="kw">let</span> <span class="ident">weak_five</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&</span><span class="ident">Rc</span>::<span class="ident">new</span>(<span class="number">5</span>)); <span class="kw">let</span> <span class="kw">_</span> <span class="op">=</span> <span class="ident">Weak</span>::<span class="ident">clone</span>(<span class="kw-2">&</span><span class="ident">weak_five</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Arc%3A%3A%7BRc%2C%20Weak%7D%3B%0A%0Alet%20weak_five%20%3D%20Rc%3A%3Adowngrade(%26Rc%3A%3Anew(5))%3B%0A%0Alet%20_%20%3D%20Weak%3A%3Aclone(%26weak_five)%3B%0A%7D">Run</a></pre></div> </div><h4 id='method.clone_from' class="method"><code id='clone_from.v'>fn <a href='../../std/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: <a class="primitive" href="../primitive.reference.html">&</a>Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/clone.rs.html#131-133' title='goto source code'>[src]</a></h4><div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="../../std/clone/trait.Clone.html#method.clone_from">Read more</a></p> </div></div><h3 id='impl-Debug' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/fmt/trait.Debug.html" title="trait std::fmt::Debug">Debug</a> for <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../std/fmt/trait.Debug.html" title="trait std::fmt::Debug">Debug</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../../src/alloc/rc.rs.html#1458-1462' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fmt' class="method hidden"><code id='fmt.v'>fn <a href='../../std/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="../../std/fmt/struct.Formatter.html" title="struct std::fmt::Formatter">Formatter</a>) -> <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a><<a class="primitive" href="../primitive.unit.html">()</a>, <a class="struct" href="../../std/fmt/struct.Error.html" title="struct std::fmt::Error">Error</a>></code><a class='srclink' href='../../src/alloc/rc.rs.html#1459-1461' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="../../std/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p> </div></div><h3 id='impl-DispatchFromDyn%3CWeak%3CU%3E%3E' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="../../std/ops/trait.DispatchFromDyn.html" title="trait std::ops::DispatchFromDyn">DispatchFromDyn</a><<a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><U>> for <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../std/marker/trait.Unsize.html" title="trait std::marker::Unsize">Unsize</a><U> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,<br> U: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-DispatchFromDyn%3CWeak%3CU%3E%3E' class='anchor'></a><a class='srclink' href='../../src/alloc/rc.rs.html#1237' title='goto source code'>[src]</a></h3><div class='impl-items'></div><h3 id='impl-Send' class='impl'><code class='in-band'>impl<T> !<a class="trait" href="../../std/marker/trait.Send.html" title="trait std::marker::Send">Send</a> for <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T> <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-Send' class='anchor'></a><a class='srclink' href='../../src/alloc/rc.rs.html#1229' title='goto source code'>[src]</a></h3><div class='impl-items'></div><h3 id='impl-CoerceUnsized%3CWeak%3CU%3E%3E' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="../../std/ops/trait.CoerceUnsized.html" title="trait std::ops::CoerceUnsized">CoerceUnsized</a><<a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><U>> for <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../std/marker/trait.Unsize.html" title="trait std::marker::Unsize">Unsize</a><U> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,<br> U: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-CoerceUnsized%3CWeak%3CU%3E%3E' class='anchor'></a><a class='srclink' href='../../src/alloc/rc.rs.html#1234' title='goto source code'>[src]</a></h3><div class='impl-items'></div><h3 id='impl-Default' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/default/trait.Default.html" title="trait std::default::Default">Default</a> for <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T></code><a href='#impl-Default' class='anchor'></a><div class='since' title='Stable since Rust version 1.10.0'>1.10.0</div><a class='srclink' href='../../src/alloc/rc.rs.html#1465-1483' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.default' class="method"><code id='default.v'>fn <a href='../../std/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -> <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T></code><a class='srclink' href='../../src/alloc/rc.rs.html#1480-1482' title='goto source code'>[src]</a></h4><div class='docblock'><p>Constructs a new <code>Weak<T></code>, allocating memory for <code>T</code> without initializing it. Calling <a href="../../std/rc/struct.Weak.html#method.upgrade"><code>upgrade</code></a> on the return value always gives <a href="../../std/option/enum.Option.html"><code>None</code></a>.</p> <h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::<span class="ident">Weak</span>; <span class="kw">let</span> <span class="ident">empty</span>: <span class="ident">Weak</span><span class="op"><</span><span class="ident">i64</span><span class="op">></span> <span class="op">=</span> <span class="ident">Default</span>::<span class="ident">default</span>(); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">empty</span>.<span class="ident">upgrade</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Arc%3A%3AWeak%3B%0A%0Alet%20empty%3A%20Weak%3Ci64%3E%20%3D%20Default%3A%3Adefault()%3B%0Aassert!(empty.upgrade().is_none())%3B%0A%7D">Run</a></pre></div> </div></div><h3 id='impl-Drop' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/ops/trait.Drop.html" title="trait std::ops::Drop">Drop</a> for <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T> <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-Drop' class='anchor'></a><a class='srclink' href='../../src/alloc/rc.rs.html#1396-1433' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.drop' class="method"><code id='drop.v'>fn <a href='../../std/ops/trait.Drop.html#tymethod.drop' class='fnname'>drop</a>(&mut self)</code><a class='srclink' href='../../src/alloc/rc.rs.html#1421-1432' title='goto source code'>[src]</a></h4><div class='docblock'><p>Drops the <code>Weak</code> pointer.</p> <h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1> <div class="example-wrap"><pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">rc</span>::{<span class="ident">Rc</span>, <span class="ident">Weak</span>}; <span class="kw">struct</span> <span class="ident">Foo</span>; <span class="kw">impl</span> <span class="ident">Drop</span> <span class="kw">for</span> <span class="ident">Foo</span> { <span class="kw">fn</span> <span class="ident">drop</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>) { <span class="macro">println</span><span class="macro">!</span>(<span class="string">"dropped!"</span>); } } <span class="kw">let</span> <span class="ident">foo</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">new</span>(<span class="ident">Foo</span>); <span class="kw">let</span> <span class="ident">weak_foo</span> <span class="op">=</span> <span class="ident">Rc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&</span><span class="ident">foo</span>); <span class="kw">let</span> <span class="ident">other_weak_foo</span> <span class="op">=</span> <span class="ident">Weak</span>::<span class="ident">clone</span>(<span class="kw-2">&</span><span class="ident">weak_foo</span>); <span class="ident">drop</span>(<span class="ident">weak_foo</span>); <span class="comment">// Doesn't print anything</span> <span class="ident">drop</span>(<span class="ident">foo</span>); <span class="comment">// Prints "dropped!"</span> <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">other_weak_foo</span>.<span class="ident">upgrade</span>().<span class="ident">is_none</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Ause%20std%3A%3Arc%3A%3A%7BRc%2C%20Weak%7D%3B%0A%0Astruct%20Foo%3B%0A%0Aimpl%20Drop%20for%20Foo%20%7B%0A%20%20%20%20fn%20drop(%26mut%20self)%20%7B%0A%20%20%20%20%20%20%20%20println!(%22dropped!%22)%3B%0A%20%20%20%20%7D%0A%7D%0A%0Alet%20foo%20%3D%20Rc%3A%3Anew(Foo)%3B%0Alet%20weak_foo%20%3D%20Rc%3A%3Adowngrade(%26foo)%3B%0Alet%20other_weak_foo%20%3D%20Weak%3A%3Aclone(%26weak_foo)%3B%0A%0Adrop(weak_foo)%3B%20%20%20%2F%2F%20Doesn't%20print%20anything%0Adrop(foo)%3B%20%20%20%20%20%20%20%20%2F%2F%20Prints%20%22dropped!%22%0A%0Aassert!(other_weak_foo.upgrade().is_none())%3B%0A%7D">Run</a></pre></div> </div></div><h3 id='impl-Sync' class='impl'><code class='in-band'>impl<T> !<a class="trait" href="../../std/marker/trait.Sync.html" title="trait std::marker::Sync">Sync</a> for <a class="struct" href="../../std/rc/struct.Weak.html" title="struct std::rc::Weak">Weak</a><T> <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-Sync' class='anchor'></a><a class='srclink' href='../../src/alloc/rc.rs.html#1231' title='goto source code'>[src]</a></h3><div class='impl-items'></div></div><h2 id='blanket-implementations' class='small-section-header'>Blanket Implementations<a href='#blanket-implementations' class='anchor'></a></h2><div id='blanket-implementations-list'><h3 id='impl-TryFrom' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="../../std/convert/trait.Into.html" title="trait std::convert::Into">Into</a><T>, </span></code><a href='#impl-TryFrom' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#565-571' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><code id='Error.t'>type <a href='../../std/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="enum" href="../../std/convert/enum.Infallible.html" title="enum std::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p> </div><h4 id='method.try_from' class="method hidden"><code id='try_from.v'>fn <a href='../../std/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -> <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a><T, <T as <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="../../std/convert/trait.TryFrom.html#associatedtype.Error" title="type std::convert::TryFrom::Error">Error</a>></code><a class='srclink' href='../../src/core/convert.rs.html#568-570' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-From' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a> for T</code><a href='#impl-From' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#546-548' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.from' class="method hidden"><code id='from.v'>fn <a href='../../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -> T</code><a class='srclink' href='../../src/core/convert.rs.html#547' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-TryInto' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="../../std/convert/trait.TryInto.html" title="trait std::convert::TryInto">TryInto</a> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><T>, </span></code><a href='#impl-TryInto' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#553-560' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error-1' class="type"><code id='Error.t-1'>type <a href='../../std/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = <U as <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="../../std/convert/trait.TryFrom.html#associatedtype.Error" title="type std::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p> </div><h4 id='method.try_into' class="method hidden"><code id='try_into.v'>fn <a href='../../std/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -> <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a><U, <U as <a class="trait" href="../../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="../../std/convert/trait.TryFrom.html#associatedtype.Error" title="type std::convert::TryFrom::Error">Error</a>></code><a class='srclink' href='../../src/core/convert.rs.html#557-559' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-Into' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="../../std/convert/trait.Into.html" title="trait std::convert::Into">Into</a> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="../../std/convert/trait.From.html" title="trait std::convert::From">From</a><T>, </span></code><a href='#impl-Into' class='anchor'></a><a class='srclink' href='../../src/core/convert.rs.html#537-542' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.into' class="method hidden"><code id='into.v'>fn <a href='../../std/convert/trait.Into.html#tymethod.into' class='fnname'>into</a>(self) -> U</code><a class='srclink' href='../../src/core/convert.rs.html#539-541' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p> </div></div><h3 id='impl-Borrow' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/borrow/trait.Borrow.html" title="trait std::borrow::Borrow">Borrow</a> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-Borrow' class='anchor'></a><a class='srclink' href='../../src/core/borrow.rs.html#213-215' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow' class="method hidden"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="../../std/marker/trait.Unpin.html" title="trait std::marker::Unpin">Unpin</a> + <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/future/trait.Future.html#associatedtype.Output' class="type">Output</a> = <F as <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a>>::<a class="type" href="../../std/future/trait.Future.html#associatedtype.Output" title="type std::future::Future::Output">Output</a>;</span><span class="where fmt-newline">impl<'_, I> <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>I <span class="where fmt-newline">where<br> I: <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a>>::<a class="type" href="../../std/iter/trait.Iterator.html#associatedtype.Item" title="type std::iter::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl<R: <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>R</span><span class="where fmt-newline">impl<W: <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>W</span></code></div></div><code id='borrow.v'>fn <a href='../../std/borrow/trait.Borrow.html#tymethod.borrow' class='fnname'>borrow</a>(&self) -> <a class="primitive" href="../primitive.reference.html">&</a>T</code><a class='srclink' href='../../src/core/borrow.rs.html#214' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="../../std/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p> </div></div><h3 id='impl-BorrowMut' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/borrow/trait.BorrowMut.html" title="trait std::borrow::BorrowMut">BorrowMut</a> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-BorrowMut' class='anchor'></a><a class='srclink' href='../../src/core/borrow.rs.html#218-220' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.borrow_mut' class="method hidden"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F</h3><code class="content"><span class="where fmt-newline">impl<'_, F> <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="../../std/marker/trait.Unpin.html" title="trait std::marker::Unpin">Unpin</a> + <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/future/trait.Future.html#associatedtype.Output' class="type">Output</a> = <F as <a class="trait" href="../../std/future/trait.Future.html" title="trait std::future::Future">Future</a>>::<a class="type" href="../../std/future/trait.Future.html#associatedtype.Output" title="type std::future::Future::Output">Output</a>;</span><span class="where fmt-newline">impl<'_, I> <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>I <span class="where fmt-newline">where<br> I: <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='../../std/iter/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="../../std/iter/trait.Iterator.html" title="trait std::iter::Iterator">Iterator</a>>::<a class="type" href="../../std/iter/trait.Iterator.html#associatedtype.Item" title="type std::iter::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl<R: <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>R</span><span class="where fmt-newline">impl<W: <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, '_> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="../primitive.reference.html">&'_ mut </a>W</span></code></div></div><code id='borrow_mut.v'>fn <a href='../../std/borrow/trait.BorrowMut.html#tymethod.borrow_mut' class='fnname'>borrow_mut</a>(&mut self) -> <a class="primitive" href="../primitive.reference.html">&mut </a>T</code><a class='srclink' href='../../src/core/borrow.rs.html#219' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="../../std/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p> </div></div><h3 id='impl-Any' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/any/trait.Any.html" title="trait std::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code><a href='#impl-Any' class='anchor'></a><a class='srclink' href='../../src/core/any.rs.html#100-102' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.type_id' class="method hidden"><code id='type_id.v'>fn <a href='../../std/any/trait.Any.html#tymethod.type_id' class='fnname'>type_id</a>(&self) -> <a class="struct" href="../../std/any/struct.TypeId.html" title="struct std::any::TypeId">TypeId</a></code><a class='srclink' href='../../src/core/any.rs.html#101' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="../../std/any/trait.Any.html#tymethod.type_id">Read more</a></p> </div></div><h3 id='impl-ToOwned' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../std/borrow/trait.ToOwned.html" title="trait std::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br> T: <a class="trait" href="../../std/clone/trait.Clone.html" title="trait std::clone::Clone">Clone</a>, </span></code><a href='#impl-ToOwned' class='anchor'></a><a class='srclink' href='../../src/alloc/borrow.rs.html#80-91' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Owned' class="type"><code id='Owned.t'>type <a href='../../std/borrow/trait.ToOwned.html#associatedtype.Owned' class="type">Owned</a> = T</code></h4><h4 id='method.to_owned' class="method hidden"><code id='to_owned.v'>fn <a href='../../std/borrow/trait.ToOwned.html#tymethod.to_owned' class='fnname'>to_owned</a>(&self) -> T</code><a class='srclink' href='../../src/alloc/borrow.rs.html#84-86' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="../../std/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p> </div><h4 id='method.clone_into' class="method hidden"><code id='clone_into.v'>fn <a href='../../std/borrow/trait.ToOwned.html#method.clone_into' class='fnname'>clone_into</a>(&self, target: <a class="primitive" href="../primitive.reference.html">&mut </a>T)</code><a class='srclink' href='../../src/alloc/borrow.rs.html#88-90' title='goto source code'>[src]</a></h4><div class='stability hidden'><div class='stab unstable'><details><summary><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code> <a href="https://github.com/rust-lang/rust/issues/41263">#41263</a>)</summary><p>recently added</p> </details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="../../std/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p> </div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "std";</script><script src="../../aliases.js"></script><script src="../../main1.35.0.js"></script><script defer src="../../search-index.js"></script></body></html>