You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
721 lines
151 KiB
721 lines
151 KiB
5 years ago
|
<!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 `AtomicCell` struct in crate `crossbeam`."><meta name="keywords" content="rust, rustlang, rust-lang, AtomicCell"><title>crossbeam::atomic::AtomicCell - 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="../../light.css" id="themeStyle"><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.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='../../crossbeam/index.html'><div class='logo-container'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Struct AtomicCell</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.compare_and_swap">compare_and_swap</a><a href="#method.compare_exchange">compare_exchange</a><a href="#method.fetch_add">fetch_add</a><a href="#method.fetch_add-1">fetch_add</a><a href="#method.fetch_add-10">fetch_add</a><a href="#method.fetch_add-11">fetch_add</a><a href="#method.fetch_add-2">fetch_add</a><a href="#method.fetch_add-3">fetch_add</a><a href="#method.fetch_add-4">fetch_add</a><a href="#method.fetch_add-5">fetch_add</a><a href="#method.fetch_add-6">fetch_add</a><a href="#method.fetch_add-7">fetch_add</a><a href="#method.fetch_add-8">fetch_add</a><a href="#method.fetch_add-9">fetch_add</a><a href="#method.fetch_and">fetch_and</a><a href="#method.fetch_and-1">fetch_and</a><a href="#method.fetch_and-10">fetch_and</a><a href="#method.fetch_and-11">fetch_and</a><a href="#method.fetch_and-12">fetch_and</a><a href="#method.fetch_and-2">fetch_and</a><a href="#method.fetch_and-3">fetch_and</a><a href="#method.fetch_and-4">fetch_and</a><a href="#method.fetch_and-5">fetch_and</a><a href="#method.fetch_and-6">fetch_and</a><a href="#method.fetch_and-7">fetch_and</a><a href="#method.fetch_and-8">fetch_and</a><a href="#method.fetch_and-9">fetch_and</a><a href="#method.fetch_or">fetch_or</a><a href="#method.fetch_or-1">fetch_or</a><a href="#method.fetch_or-10">fetch_or</a><a href="#method.fetch_or-11">fetch_or</a><a href="#method.fetch_or-12">fetch_or</a><a href="#method.fetch_or-2">fetch_or</a><a href="#method.fetch_or-3">fetch_or</a><a href="#method.fetch_or-4">fetch_or</a><a href="#method.fetch_or-5">fetch_or</a><a href="#method.fetch_or-6">fetch_or</a><a href="#method.fetch_or-7">fetch_or</a><a href="#method.fetch_or-8">fetch_or</a><a href="#method.fetch_or-9">fetch_or</a><a href="#method.fetch_sub">fetch_sub</a><a href="#method.fetch_sub-1">fetch_sub</a><a href="#method.fetch_sub-10">fetch_sub</a><a href="#method.fetch_sub-11">fetch_sub</a><a href="#method.fetch_sub-2">fetch_sub</a><a href="#method.fetch_sub-3">fetch_sub</a><a href="#method.fetch_sub-4">fetch_sub</a><a href="#method.fetch_sub-5">fetch_sub</a><a href="#method.fetch_sub-6">fetch_sub</a><a href="#method.fetch_sub-7">fetch_sub</a><a href="#method.fetch_sub-8">fetch_sub</a><a href="#method.fetch_sub-9">fetch_sub</a><a href="#method.fetch_xor">fetch_xor</a><a href="#method.fetch_xor-1">fetch_xor</a><a href="#method.fetch_xor-10">fetch_xor</a><a href="#method.fetch_xor-11">fetch_xor</a><a href="#method.fetch_xor-12">fetch_xor</a><a href="#method.fetch_xor-2">fetch_xor</a><a href="#method.fetch_xor-3">fetch_xor</a><a href="#method.fetch_xor-4">fetch_xor</a><a href="#method.fetch_xor-5">fetch_xor</a><a href="#metho
|
||
|
<p>This type is equivalent to <a href="https://doc.rust-lang.org/std/cell/struct.Cell.html"><code>Cell</code></a>, except it can also be shared among multiple threads.</p>
|
||
|
<p>Operations on <code>AtomicCell</code>s use atomic instructions whenever possible, and synchronize using
|
||
|
global locks otherwise. You can call <a href="struct.AtomicCell.html#method.is_lock_free"><code>AtomicCell::<T>::is_lock_free()</code></a> to check whether
|
||
|
atomic instructions or locks will be used.</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="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T></code><a href='#impl' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#32-151' 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>(val: T) -> <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#42-46' title='goto source code'>[src]</a></h4><div class='docblock'><p>Creates a new atomic cell initialized with <code>val</code>.</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">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7</span>);</pre></div>
|
||
|
</div><h4 id='method.get_mut' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>W</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>W</h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>W <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline">impl<'_, R> <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>R <span class="where fmt-newline">where<br> R: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline">impl<'_, I> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>I <span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::traits::iterator::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html#associatedtype.Output' class="type">Output</a> = <F as <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" tit
|
||
|
<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">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7</span>);
|
||
|
<span class="kw-2">*</span><span class="ident">a</span>.<span class="ident">get_mut</span>() <span class="op">+</span><span class="op">=</span> <span class="number">1</span>;
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">8</span>);</pre></div>
|
||
|
</div><h4 id='method.into_inner' class="method"><code id='into_inner.v'>pub fn <a href='#method.into_inner' class='fnname'>into_inner</a>(self) -> T</code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#76-78' title='goto source code'>[src]</a></h4><div class='docblock'><p>Unwraps the atomic cell and returns its inner 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="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7</span>);
|
||
|
<span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">into_inner</span>();
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, <span class="number">7</span>);</pre></div>
|
||
|
</div><h4 id='method.is_lock_free' class="method"><code id='is_lock_free.v'>pub fn <a href='#method.is_lock_free' class='fnname'>is_lock_free</a>() -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#108-110' title='goto source code'>[src]</a></h4><div class='docblock'><p>Returns <code>true</code> if operations on values of this type are lock-free.</p>
|
||
|
<p>If the compiler or the platform doesn't support the necessary atomic instructions,
|
||
|
<code>AtomicCell<T></code> will use global locks for every potentially concurrent atomic operation.</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">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="comment">// This type is internally represented as `AtomicUsize` so we can just use atomic</span>
|
||
|
<span class="comment">// operations provided by it.</span>
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">AtomicCell</span>::<span class="op"><</span><span class="ident">usize</span><span class="op">></span>::<span class="ident">is_lock_free</span>(), <span class="bool-val">true</span>);
|
||
|
|
||
|
<span class="comment">// A wrapper struct around `isize`.</span>
|
||
|
<span class="kw">struct</span> <span class="ident">Foo</span> {
|
||
|
<span class="ident">bar</span>: <span class="ident">isize</span>,
|
||
|
}
|
||
|
<span class="comment">// `AtomicCell<Foo>` will be internally represented as `AtomicIsize`.</span>
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">AtomicCell</span>::<span class="op"><</span><span class="ident">Foo</span><span class="op">></span>::<span class="ident">is_lock_free</span>(), <span class="bool-val">true</span>);
|
||
|
|
||
|
<span class="comment">// Operations on zero-sized types are always lock-free.</span>
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">AtomicCell</span>::<span class="op"><</span>()<span class="op">></span>::<span class="ident">is_lock_free</span>(), <span class="bool-val">true</span>);
|
||
|
|
||
|
<span class="comment">// Very large types cannot be represented as any of the standard atomic types, so atomic</span>
|
||
|
<span class="comment">// operations on them will have to use global locks for synchronization.</span>
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">AtomicCell</span>::<span class="op"><</span>[<span class="ident">u8</span>; <span class="number">1000</span>]<span class="op">></span>::<span class="ident">is_lock_free</span>(), <span class="bool-val">false</span>);</pre></div>
|
||
|
</div><h4 id='method.store' class="method"><code id='store.v'>pub fn <a href='#method.store' class='fnname'>store</a>(&self, val: T)</code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#125-133' title='goto source code'>[src]</a></h4><div class='docblock'><p>Stores <code>val</code> into the atomic cell.</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">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">7</span>);
|
||
|
<span class="ident">a</span>.<span class="ident">store</span>(<span class="number">8</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">8</span>);</pre></div>
|
||
|
</div><h4 id='method.swap' class="method"><code id='swap.v'>pub fn <a href='#method.swap' class='fnname'>swap</a>(&self, val: T) -> T</code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#148-150' title='goto source code'>[src]</a></h4><div class='docblock'><p>Stores <code>val</code> into the atomic cell and returns the previous value.</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">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">swap</span>(<span class="number">8</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">8</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-1' class='impl'><code class='in-band'>impl<T> <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a>, </span></code><a href='#impl-1' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#153-168' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.load' class="method"><code id='load.v'>pub fn <a href='#method.load' class='fnname'>load</a>(&self) -> T</code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#165-167' title='goto source code'>[src]</a></h4><div class='docblock'><p>Loads a value.</p>
|
||
|
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">7</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-2' class='impl'><code class='in-band'>impl<T> <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>, </span></code><a href='#impl-2' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#170-232' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.compare_and_swap' class="method"><code id='compare_and_swap.v'>pub fn <a href='#method.compare_and_swap' class='fnname'>compare_and_swap</a>(&self, current: T, new: T) -> T</code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#189-194' title='goto source code'>[src]</a></h4><div class='docblock'><p>If the current value equals <code>current</code>, stores <code>new</code> into the atomic cell.</p>
|
||
|
<p>The return value is always the previous value. If it is equal to <code>current</code>, then the value
|
||
|
was updated.</p>
|
||
|
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">1</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">compare_exchange</span>(<span class="number">2</span>, <span class="number">3</span>), <span class="prelude-val">Err</span>(<span class="number">1</span>));
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">1</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">compare_exchange</span>(<span class="number">1</span>, <span class="number">2</span>), <span class="prelude-val">Ok</span>(<span class="number">1</span>));
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">2</span>);</pre></div>
|
||
|
</div><h4 id='method.compare_exchange' class="method"><code id='compare_exchange.v'>pub fn <a href='#method.compare_exchange' class='fnname'>compare_exchange</a>(&self, current: T, new: T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, T></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#214-231' title='goto source code'>[src]</a></h4><div class='docblock'><p>If the current value equals <code>current</code>, stores <code>new</code> into the atomic cell.</p>
|
||
|
<p>The return value is a result indicating whether the new value was written and containing
|
||
|
the previous value. On success this value is guaranteed to be equal to <code>current</code>.</p>
|
||
|
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">1</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">compare_exchange</span>(<span class="number">2</span>, <span class="number">3</span>), <span class="prelude-val">Err</span>(<span class="number">1</span>));
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">1</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">compare_exchange</span>(<span class="number">1</span>, <span class="number">2</span>), <span class="prelude-val">Ok</span>(<span class="number">1</span>));
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">2</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-3' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a href='#impl-3' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#512-575' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_and' class="method"><code id='fetch_and.v'>pub fn <a href='#method.fetch_and' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#529-532' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies logical "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="bool-val">true</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="bool-val">true</span>), <span class="bool-val">true</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="bool-val">true</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="bool-val">false</span>), <span class="bool-val">true</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="bool-val">false</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or' class="method"><code id='fetch_or.v'>pub fn <a href='#method.fetch_or' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#550-553' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies logical "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="bool-val">false</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="bool-val">false</span>), <span class="bool-val">false</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="bool-val">false</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="bool-val">true</span>), <span class="bool-val">false</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="bool-val">true</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor' class="method"><code id='fetch_xor.v'>pub fn <a href='#method.fetch_xor' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#571-574' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies logical "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="bool-val">true</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="bool-val">false</span>), <span class="bool-val">true</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="bool-val">true</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="bool-val">true</span>), <span class="bool-val">true</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="bool-val">false</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-4' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>></code><a href='#impl-4' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add' class="method"><code id='fetch_add.v'>pub fn <a href='#method.fetch_add' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub' class="method"><code id='fetch_sub.v'>pub fn <a href='#method.fetch_sub' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-1' class="method"><code id='fetch_and.v-1'>pub fn <a href='#method.fetch_and-1' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-1' class="method"><code id='fetch_or.v-1'>pub fn <a href='#method.fetch_or-1' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-1' class="method"><code id='fetch_xor.v-1'>pub fn <a href='#method.fetch_xor-1' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-5' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>></code><a href='#impl-5' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-1' class="method"><code id='fetch_add.v-1'>pub fn <a href='#method.fetch_add-1' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-17" class="section-header"><a href="#examples-17">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-1' class="method"><code id='fetch_sub.v-1'>pub fn <a href='#method.fetch_sub-1' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-18" class="section-header"><a href="#examples-18">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-2' class="method"><code id='fetch_and.v-2'>pub fn <a href='#method.fetch_and-2' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-19" class="section-header"><a href="#examples-19">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-2' class="method"><code id='fetch_or.v-2'>pub fn <a href='#method.fetch_or-2' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-20" class="section-header"><a href="#examples-20">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-2' class="method"><code id='fetch_xor.v-2'>pub fn <a href='#method.fetch_xor-2' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-21" class="section-header"><a href="#examples-21">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i8</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-6' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>></code><a href='#impl-6' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-2' class="method"><code id='fetch_add.v-2'>pub fn <a href='#method.fetch_add-2' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-22" class="section-header"><a href="#examples-22">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-2' class="method"><code id='fetch_sub.v-2'>pub fn <a href='#method.fetch_sub-2' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-23" class="section-header"><a href="#examples-23">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-3' class="method"><code id='fetch_and.v-3'>pub fn <a href='#method.fetch_and-3' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-24" class="section-header"><a href="#examples-24">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-3' class="method"><code id='fetch_or.v-3'>pub fn <a href='#method.fetch_or-3' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-25" class="section-header"><a href="#examples-25">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-3' class="method"><code id='fetch_xor.v-3'>pub fn <a href='#method.fetch_xor-3' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-26" class="section-header"><a href="#examples-26">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-7' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>></code><a href='#impl-7' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-3' class="method"><code id='fetch_add.v-3'>pub fn <a href='#method.fetch_add-3' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-27" class="section-header"><a href="#examples-27">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-3' class="method"><code id='fetch_sub.v-3'>pub fn <a href='#method.fetch_sub-3' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-28" class="section-header"><a href="#examples-28">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-4' class="method"><code id='fetch_and.v-4'>pub fn <a href='#method.fetch_and-4' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-29" class="section-header"><a href="#examples-29">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-4' class="method"><code id='fetch_or.v-4'>pub fn <a href='#method.fetch_or-4' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-30" class="section-header"><a href="#examples-30">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-4' class="method"><code id='fetch_xor.v-4'>pub fn <a href='#method.fetch_xor-4' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-31" class="section-header"><a href="#examples-31">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i16</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-8' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>></code><a href='#impl-8' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-4' class="method"><code id='fetch_add.v-4'>pub fn <a href='#method.fetch_add-4' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-32" class="section-header"><a href="#examples-32">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-4' class="method"><code id='fetch_sub.v-4'>pub fn <a href='#method.fetch_sub-4' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-33" class="section-header"><a href="#examples-33">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-5' class="method"><code id='fetch_and.v-5'>pub fn <a href='#method.fetch_and-5' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-34" class="section-header"><a href="#examples-34">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-5' class="method"><code id='fetch_or.v-5'>pub fn <a href='#method.fetch_or-5' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-35" class="section-header"><a href="#examples-35">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-5' class="method"><code id='fetch_xor.v-5'>pub fn <a href='#method.fetch_xor-5' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-36" class="section-header"><a href="#examples-36">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-9' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>></code><a href='#impl-9' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-5' class="method"><code id='fetch_add.v-5'>pub fn <a href='#method.fetch_add-5' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-37" class="section-header"><a href="#examples-37">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-5' class="method"><code id='fetch_sub.v-5'>pub fn <a href='#method.fetch_sub-5' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-38" class="section-header"><a href="#examples-38">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-6' class="method"><code id='fetch_and.v-6'>pub fn <a href='#method.fetch_and-6' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-39" class="section-header"><a href="#examples-39">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-6' class="method"><code id='fetch_or.v-6'>pub fn <a href='#method.fetch_or-6' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-40" class="section-header"><a href="#examples-40">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-6' class="method"><code id='fetch_xor.v-6'>pub fn <a href='#method.fetch_xor-6' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-41" class="section-header"><a href="#examples-41">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i32</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-10' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>></code><a href='#impl-10' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-6' class="method"><code id='fetch_add.v-6'>pub fn <a href='#method.fetch_add-6' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-42" class="section-header"><a href="#examples-42">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-6' class="method"><code id='fetch_sub.v-6'>pub fn <a href='#method.fetch_sub-6' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-43" class="section-header"><a href="#examples-43">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-7' class="method"><code id='fetch_and.v-7'>pub fn <a href='#method.fetch_and-7' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-44" class="section-header"><a href="#examples-44">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-7' class="method"><code id='fetch_or.v-7'>pub fn <a href='#method.fetch_or-7' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-45" class="section-header"><a href="#examples-45">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-7' class="method"><code id='fetch_xor.v-7'>pub fn <a href='#method.fetch_xor-7' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-46" class="section-header"><a href="#examples-46">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-11' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>></code><a href='#impl-11' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-7' class="method"><code id='fetch_add.v-7'>pub fn <a href='#method.fetch_add-7' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-47" class="section-header"><a href="#examples-47">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-7' class="method"><code id='fetch_sub.v-7'>pub fn <a href='#method.fetch_sub-7' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-48" class="section-header"><a href="#examples-48">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-8' class="method"><code id='fetch_and.v-8'>pub fn <a href='#method.fetch_and-8' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-49" class="section-header"><a href="#examples-49">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-8' class="method"><code id='fetch_or.v-8'>pub fn <a href='#method.fetch_or-8' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-50" class="section-header"><a href="#examples-50">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-8' class="method"><code id='fetch_xor.v-8'>pub fn <a href='#method.fetch_xor-8' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-51" class="section-header"><a href="#examples-51">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i64</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-12' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>></code><a href='#impl-12' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-8' class="method"><code id='fetch_add.v-8'>pub fn <a href='#method.fetch_add-8' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-52" class="section-header"><a href="#examples-52">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-8' class="method"><code id='fetch_sub.v-8'>pub fn <a href='#method.fetch_sub-8' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-53" class="section-header"><a href="#examples-53">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-9' class="method"><code id='fetch_and.v-9'>pub fn <a href='#method.fetch_and-9' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-54" class="section-header"><a href="#examples-54">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-9' class="method"><code id='fetch_or.v-9'>pub fn <a href='#method.fetch_or-9' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-55" class="section-header"><a href="#examples-55">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-9' class="method"><code id='fetch_xor.v-9'>pub fn <a href='#method.fetch_xor-9' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-56" class="section-header"><a href="#examples-56">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7u128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-13' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>></code><a href='#impl-13' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#236-370' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-9' class="method"><code id='fetch_add.v-9'>pub fn <a href='#method.fetch_add-9' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#252-263' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-57" class="section-header"><a href="#examples-57">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-9' class="method"><code id='fetch_sub.v-9'>pub fn <a href='#method.fetch_sub-9' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#280-291' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-58" class="section-header"><a href="#examples-58">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-10' class="method"><code id='fetch_and.v-10'>pub fn <a href='#method.fetch_and-10' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#306-317' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-59" class="section-header"><a href="#examples-59">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-10' class="method"><code id='fetch_or.v-10'>pub fn <a href='#method.fetch_or-10' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#332-343' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-60" class="section-header"><a href="#examples-60">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-10' class="method"><code id='fetch_xor.v-10'>pub fn <a href='#method.fetch_xor-10' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#358-369' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-61" class="section-header"><a href="#examples-61">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7i128</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-14' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a href='#impl-14' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#373-467' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-10' class="method"><code id='fetch_add.v-10'>pub fn <a href='#method.fetch_add-10' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#389-392' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-62" class="section-header"><a href="#examples-62">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7usize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-10' class="method"><code id='fetch_sub.v-10'>pub fn <a href='#method.fetch_sub-10' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#409-412' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-63" class="section-header"><a href="#examples-63">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7usize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-11' class="method"><code id='fetch_and.v-11'>pub fn <a href='#method.fetch_and-11' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#427-430' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-64" class="section-header"><a href="#examples-64">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7usize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-11' class="method"><code id='fetch_or.v-11'>pub fn <a href='#method.fetch_or-11' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#445-448' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-65" class="section-header"><a href="#examples-65">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7usize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-11' class="method"><code id='fetch_xor.v-11'>pub fn <a href='#method.fetch_xor-11' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#463-466' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-66" class="section-header"><a href="#examples-66">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7usize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</pre></div>
|
||
|
</div></div><h3 id='impl-15' class='impl'><code class='in-band'>impl <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a>></code><a href='#impl-15' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#373-467' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.fetch_add-11' class="method"><code id='fetch_add.v-11'>pub fn <a href='#method.fetch_add-11' class='fnname'>fetch_add</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#389-392' title='goto source code'>[src]</a></h4><div class='docblock'><p>Increments the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The addition wraps on overflow.</p>
|
||
|
<h1 id="examples-67" class="section-header"><a href="#examples-67">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7isize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_add</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">10</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_sub-11' class="method"><code id='fetch_sub.v-11'>pub fn <a href='#method.fetch_sub-11' class='fnname'>fetch_sub</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#409-412' title='goto source code'>[src]</a></h4><div class='docblock'><p>Decrements the current value by <code>val</code> and returns the previous value.</p>
|
||
|
<p>The subtraction wraps on overflow.</p>
|
||
|
<h1 id="examples-68" class="section-header"><a href="#examples-68">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7isize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_sub</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">4</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_and-12' class="method"><code id='fetch_and.v-12'>pub fn <a href='#method.fetch_and-12' class='fnname'>fetch_and</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#427-430' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "and" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-69" class="section-header"><a href="#examples-69">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7isize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_and</span>(<span class="number">3</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">3</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_or-12' class="method"><code id='fetch_or.v-12'>pub fn <a href='#method.fetch_or-12' class='fnname'>fetch_or</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#445-448' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "or" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-70" class="section-header"><a href="#examples-70">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7isize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_or</span>(<span class="number">16</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">23</span>);</pre></div>
|
||
|
</div><h4 id='method.fetch_xor-12' class="method"><code id='fetch_xor.v-12'>pub fn <a href='#method.fetch_xor-12' class='fnname'>fetch_xor</a>(&self, val: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#463-466' title='goto source code'>[src]</a></h4><div class='docblock'><p>Applies bitwise "xor" to the current value and returns the previous value.</p>
|
||
|
<h1 id="examples-71" class="section-header"><a href="#examples-71">Examples</a></h1>
|
||
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
|
<span class="kw">use</span> <span class="ident">crossbeam_utils</span>::<span class="ident">atomic</span>::<span class="ident">AtomicCell</span>;
|
||
|
|
||
|
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> <span class="ident">AtomicCell</span>::<span class="ident">new</span>(<span class="number">7isize</span>);
|
||
|
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">fetch_xor</span>(<span class="number">2</span>), <span class="number">7</span>);
|
||
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">load</span>(), <span class="number">5</span>);</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-Debug' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>, </span></code><a href='#impl-Debug' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#583-589' 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='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#584-588' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
||
|
</div></div><h3 id='impl-Default' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>, </span></code><a href='#impl-Default' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#577-581' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.default' class="method hidden"><code id='default.v'>fn <a href='https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -> <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T></code><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#578-580' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Returns the "default value" for a type. <a href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default">Read more</a></p>
|
||
|
</div></div><h3 id='impl-Sync' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-Sync' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#30' 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="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-Send' class='anchor'></a><a class='srclink' href='../../src/crossbeam_utils/atomic/atomic_cell.rs.html#29' title='goto source code'>[src]</a></h3><div class='impl-items'></div></div><h2 id='synthetic-implementations' class='small-section-header'>Auto Trait Implementations<a href='#synthetic-implementations' class='anchor'></a></h2><div id='synthetic-implementations-list'><h3 id='impl-Unpin' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>, </span></code><a href='#impl-Unpin' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-UnwindSafe' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a>, </span></code><a href='#impl-UnwindSafe' class='anchor'></a></h3><div class='impl-items'></div><h3 id='impl-RefUnwindSafe' class='impl'><code class='in-band'>impl<T> !<a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../../crossbeam/atomic/struct.AtomicCell.html" title="struct crossbeam::atomic::AtomicCell">AtomicCell</a><T></code><a href='#impl-RefUnwindSafe' class='anchor'></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-Into%3CU%3E' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>
|
||
|
</div></div><h3 id='impl-From%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</code><a href='#impl-From%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#553-555' 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='https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(t: T) -> T</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#554' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
|
</div></div><h3 id='impl-TryFrom%3CU%3E' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>, </span></code><a href='#impl-TryFrom%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#572-578' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Error' class="type"><code id='Error.t'>type <a href='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::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='https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#575-577' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
|
</div></div><h3 id='impl-TryInto%3CU%3E' class='impl'><code class='in-band'>impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T <span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>, </span></code><a href='#impl-TryInto%3CU%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#560-567' 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='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error' class="type">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::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='https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into' class='fnname'>try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/convert.rs.html#564-566' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
|
</div></div><h3 id='impl-BorrowMut%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href='#impl-BorrowMut%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/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="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>W</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>W</h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>W <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline">impl<'_, R> <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>R <span class="where fmt-newline">where<br> R: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline">impl<'_, I> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>I <span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::traits::iterator::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://d
|
||
|
</div></div><h3 id='impl-Borrow%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T <span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href='#impl-Borrow%3CT%3E' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/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="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>W</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>W</h3><code class="content"><span class="where fmt-newline">impl<'_, W> <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>W <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline">impl<'_, R> <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>R <span class="where fmt-newline">where<br> R: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline">impl<'_, I> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>I <span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::traits::iterator::Iterator::Item">Item</a>;</span><span class="where fmt-newline">impl<'_, F> <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'_ mut </a>F <span class="where fmt-newline">where<br> F: <a class="trait" href="https://doc.rust-lang.org/ni
|
||
|
</div></div><h3 id='impl-Any' class='impl'><code class='in-band'>impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href='#impl-Any' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/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='https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id' class='fnname'>type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/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="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">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 = "crossbeam";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|