Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-updates > by-pkgid > fdedb3cf2140df9b6d419a2338ab1caa > files > 5920

rust-doc-1.25.0-1.mga6.x86_64.rpm

<!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::sync::Weak - Rust</title>

    <link rel="stylesheet" type="text/css" href="../../normalize.css">
    <link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle">
    
    <link rel="stylesheet" type="text/css" href="../../dark.css">
    <link rel="stylesheet" type="text/css" href="../../main.css" id="themeStyle">
    <script src="../../storage.js"></script>
    

    <link rel="shortcut icon" href="https://doc.rust-lang.org/favicon.ico">
    
</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">&#9776;</div>
        <a href='../../std/index.html'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.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.upgrade">upgrade</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-CoerceUnsized%3CWeak%3CU%3E%3E">CoerceUnsized&lt;Weak&lt;U&gt;&gt;</a><a href="#impl-Sync">Sync</a><a href="#impl-Clone">Clone</a><a href="#impl-Default">Default</a><a href="#impl-Debug">Debug</a><a href="#impl-Drop">Drop</a><a href="#impl-Send">Send</a></div></div><p class='location'><a href='../index.html'>std</a>::<wbr><a href='index.html'>sync</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="../../brush.svg" width="18" alt="Pick another theme!">
        </button>
        <div id="theme-choices"></div>
    </div>
    <script src="../../theme.js"></script>
    <nav class="sub">
        <form class="search-form js-only">
            <div class="search-container">
                <input class="search-input" name="search"
                       autocomplete="off"
                       placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
                       type="search">
            </div>
        </form>
    </nav>

    <section id='main' class="content">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>std</a>::<wbr><a href='index.html'>sync</a>::<wbr><a class="struct" href=''>Weak</a></span><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'>&#x2212;</span>]
                   </a>
               </span><a class='srclink' href='../../src/alloc/arc.rs.html#236-238' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Weak&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span> { /* fields omitted */ }</pre><div class='docblock'><p><code>Weak</code> is a version of <a href="struct.Arc.html"><code>Arc</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>&lt;</code><a href="struct.Arc.html"><code>Arc</code></a><code>&lt;T&gt;&gt;</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.Arc.html"><code>Arc</code></a> without extending its lifetime. It is also used to prevent
circular references between <a href="struct.Arc.html"><code>Arc</code></a> pointers, since mutual owning references
would never allow either <a href="struct.Arc.html"><code>Arc</code></a> to be dropped. For example, a tree could
have strong <a href="struct.Arc.html"><code>Arc</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.Arc.html#method.downgrade"><code>Arc::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'><span class='in-band'><code>impl&lt;T&gt; <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt;</code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#975-1002' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>pub fn <a href='#method.new' class='fnname'>new</a>() -&gt; <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt;</code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.10.0'>1.10.0</div><a class='srclink' href='../../src/alloc/arc.rs.html#991-1001' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Constructs a new <code>Weak&lt;T&gt;</code>, allocating memory for <code>T</code> without initializing
it. Calling <a href="struct.Weak.html#method.upgrade"><code>upgrade</code></a> on the return value always gives <a href="../../std/option/enum.Option.html#variant.None"><code>None</code></a>.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">Weak</span>;

<span class="kw">let</span> <span class="ident">empty</span>: <span class="ident">Weak</span><span class="op">&lt;</span><span class="ident">i64</span><span class="op">&gt;</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%3Async%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><h3 id='impl-1' class='impl'><span class='in-band'><code>impl&lt;T&gt; <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-1' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#1004-1068' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.upgrade' class="method"><span id='upgrade.v' class='invisible'><code>pub fn <a href='#method.upgrade' class='fnname'>upgrade</a>(&amp;self) -&gt; <a class="enum" href="../../std/option/enum.Option.html" title="enum std::option::Option">Option</a>&lt;<a class="struct" href="../../std/sync/struct.Arc.html" title="struct std::sync::Arc">Arc</a>&lt;T&gt;&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#1032-1061' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Attempts to upgrade the <code>Weak</code> pointer to an <a href="struct.Arc.html"><code>Arc</code></a>, extending
the lifetime of the value if successful.</p>
<p>Returns <a href="../../std/option/enum.Option.html#variant.None"><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>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">Arc</span>;

<span class="kw">let</span> <span class="ident">five</span> <span class="op">=</span> <span class="ident">Arc</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">Arc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&amp;</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">&lt;</span><span class="ident">Arc</span><span class="op">&lt;</span>_<span class="op">&gt;&gt;</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%3Async%3A%3AArc%3B%0A%0Alet%20five%20%3D%20Arc%3A%3Anew(5)%3B%0A%0Alet%20weak_five%20%3D%20Arc%3A%3Adowngrade(%26five)%3B%0A%0Alet%20strong_five%3A%20Option%3CArc%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>
            <h2 id='implementations' class='small-section-header'>
              Trait Implementations<a href='#implementations' class='anchor'></a>
            </h2>
        <h3 id='impl-CoerceUnsized%3CWeak%3CU%3E%3E' class='impl'><span class='in-band'><code>impl&lt;T, U&gt; <a class="trait" href="../../std/ops/trait.CoerceUnsized.html" title="trait std::ops::CoerceUnsized">CoerceUnsized</a>&lt;<a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;U&gt;&gt; for <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/marker/trait.Unsize.html" title="trait std::marker::Unsize">Unsize</a>&lt;U&gt; + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;U: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-CoerceUnsized%3CWeak%3CU%3E%3E' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#246' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 id='impl-Sync' class='impl'><span class='in-band'><code>impl&lt;T&gt; <a class="trait" href="../../std/marker/trait.Sync.html" title="trait std::marker::Sync">Sync</a> for <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/marker/trait.Send.html" title="trait std::marker::Send">Send</a> + <a class="trait" href="../../std/marker/trait.Sync.html" title="trait std::marker::Sync">Sync</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Sync' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#243' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></div><h3 id='impl-Clone' class='impl'><span class='in-band'><code>impl&lt;T&gt; <a class="trait" href="../../std/clone/trait.Clone.html" title="trait std::clone::Clone">Clone</a> for <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Clone' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#1071-1100' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.clone' class="method"><span id='clone.v' class='invisible'><code>fn <a href='../../std/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&amp;self) -&gt; <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#1084-1099' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Makes a clone of the <code>Weak</code> pointer that points to the same value.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::{<span class="ident">Arc</span>, <span class="ident">Weak</span>};

<span class="kw">let</span> <span class="ident">weak_five</span> <span class="op">=</span> <span class="ident">Arc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&amp;</span><span class="ident">Arc</span>::<span class="ident">new</span>(<span class="number">5</span>));

<span class="ident">Weak</span>::<span class="ident">clone</span>(<span class="kw-2">&amp;</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%3Async%3A%3A%7BArc%2C%20Weak%7D%3B%0A%0Alet%20weak_five%20%3D%20Arc%3A%3Adowngrade(%26Arc%3A%3Anew(5))%3B%0A%0AWeak%3A%3Aclone(%26weak_five)%3B%0A%7D">Run</a></pre>
</div><h4 id='method.clone_from' class="method"><span id='clone_from.v' class='invisible'><code>fn <a href='../../std/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: <a class="primitive" href="../primitive.reference.html">&amp;</a>Self)</code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div><a class='srclink' href='../../src/core/clone.rs.html#112-114' title='goto source code'>[src]</a></span></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-Default' class='impl'><span class='in-band'><code>impl&lt;T&gt; <a class="trait" href="../../std/default/trait.Default.html" title="trait std::default::Default">Default</a> for <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt;</code><a href='#impl-Default' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.10.0'>1.10.0</div><a class='srclink' href='../../src/alloc/arc.rs.html#1103-1121' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.default' class="method"><span id='default.v' class='invisible'><code>fn <a href='../../std/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -&gt; <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#1118-1120' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Constructs a new <code>Weak&lt;T&gt;</code>, allocating memory for <code>T</code> without initializing
it. Calling <a href="struct.Weak.html#method.upgrade"><code>upgrade</code></a> on the return value always gives <a href="../../std/option/enum.Option.html#variant.None"><code>None</code></a>.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">Weak</span>;

<span class="kw">let</span> <span class="ident">empty</span>: <span class="ident">Weak</span><span class="op">&lt;</span><span class="ident">i64</span><span class="op">&gt;</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%3Async%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><h3 id='impl-Debug' class='impl'><span class='in-band'><code>impl&lt;T&gt; <a class="trait" href="../../std/fmt/trait.Debug.html" title="trait std::fmt::Debug">Debug</a> for <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;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>,&nbsp;</span></code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#249-253' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='../../std/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="../../std/fmt/struct.Formatter.html" title="struct std::fmt::Formatter">Formatter</a>) -&gt; <a class="enum" href="../../std/result/enum.Result.html" title="enum std::result::Result">Result</a>&lt;<a class="primitive" href="../primitive.unit.html">()</a>, <a class="struct" href="../../std/fmt/struct.Error.html" title="struct std::fmt::Error">Error</a>&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#250-252' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><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-Drop' class='impl'><span class='in-band'><code>impl&lt;T&gt; <a class="trait" href="../../std/ops/trait.Drop.html" title="trait std::ops::Drop">Drop</a> for <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Drop' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#1124-1167' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.drop' class="method"><span id='drop.v' class='invisible'><code>fn <a href='../../std/ops/trait.Drop.html#tymethod.drop' class='fnname'>drop</a>(&amp;mut self)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#1149-1166' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Drops the <code>Weak</code> pointer.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::{<span class="ident">Arc</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">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>) {
        <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;dropped!&quot;</span>);
    }
}

<span class="kw">let</span> <span class="ident">foo</span> <span class="op">=</span> <span class="ident">Arc</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">Arc</span>::<span class="ident">downgrade</span>(<span class="kw-2">&amp;</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">&amp;</span><span class="ident">weak_foo</span>);

<span class="ident">drop</span>(<span class="ident">weak_foo</span>);   <span class="comment">// Doesn&#39;t print anything</span>
<span class="ident">drop</span>(<span class="ident">foo</span>);        <span class="comment">// Prints &quot;dropped!&quot;</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%3Async%3A%3A%7BArc%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%20Arc%3A%3Anew(Foo)%3B%0Alet%20weak_foo%20%3D%20Arc%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><h3 id='impl-Send' class='impl'><span class='in-band'><code>impl&lt;T&gt; <a class="trait" href="../../std/marker/trait.Send.html" title="trait std::marker::Send">Send</a> for <a class="struct" href="../../std/sync/struct.Weak.html" title="struct std::sync::Weak">Weak</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../../std/marker/trait.Send.html" title="trait std::marker::Send">Send</a> + <a class="trait" href="../../std/marker/trait.Sync.html" title="trait std::marker::Sync">Sync</a> + ?<a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>,&nbsp;</span></code><a href='#impl-Send' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/alloc/arc.rs.html#241' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'></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>&#9166;</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>
            </div>
        </div>
    </aside>

    

    <script>
        window.rootPath = "../../";
        window.currentCrate = "std";
    </script>
    <script src="../../main.js"></script>
    <script defer src="../../search-index.js"></script>
</body>
</html>