257 lines
48 KiB
HTML
257 lines
48 KiB
HTML
<!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="A guard that keeps the current thread pinned."><title>Guard in crossbeam_epoch - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="crossbeam_epoch" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Guard</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../crossbeam_epoch/index.html">crossbeam_<wbr>epoch</a><span class="version">0.9.18</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Guard</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#pinning" title="Pinning">Pinning</a></li><li><a href="#pointers-on-the-stack" title="Pointers on the stack">Pointers on the stack</a></li><li><a href="#multiple-guards" title="Multiple guards">Multiple guards</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.collector" title="collector">collector</a></li><li><a href="#method.defer" title="defer">defer</a></li><li><a href="#method.defer_destroy" title="defer_destroy">defer_destroy</a></li><li><a href="#method.defer_unchecked" title="defer_unchecked">defer_unchecked</a></li><li><a href="#method.flush" title="flush">flush</a></li><li><a href="#method.repin" title="repin">repin</a></li><li><a href="#method.repin_after" title="repin_after">repin_after</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-Guard" title="Debug">Debug</a></li><li><a href="#impl-Drop-for-Guard" title="Drop">Drop</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-RefUnwindSafe-for-Guard" title="!RefUnwindSafe">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-Guard" title="!Send">!Send</a></li><li><a href="#impl-Sync-for-Guard" title="!Sync">!Sync</a></li><li><a href="#impl-UnwindSafe-for-Guard" title="!UnwindSafe">!UnwindSafe</a></li><li><a href="#impl-Freeze-for-Guard" title="Freeze">Freeze</a></li><li><a href="#impl-Unpin-for-Guard" title="Unpin">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-Pointable-for-T" title="Pointable">Pointable</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate crossbeam_<wbr>epoch</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">crossbeam_epoch</a></div><h1>Struct <span class="struct">Guard</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/crossbeam_epoch/guard.rs.html#69-71">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Guard { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A guard that keeps the current thread pinned.</p>
|
||
<h2 id="pinning"><a class="doc-anchor" href="#pinning">§</a>Pinning</h2>
|
||
<p>The current thread is pinned by calling <a href="fn.pin.html" title="fn crossbeam_epoch::pin"><code>pin</code></a>, which returns a new guard:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch <span class="kw">as </span>epoch;
|
||
|
||
<span class="comment">// It is often convenient to prefix a call to `pin` with a `&` in order to create a reference.
|
||
// This is not really necessary, but makes passing references to the guard a bit easier.
|
||
</span><span class="kw">let </span>guard = <span class="kw-2">&</span>epoch::pin();</code></pre></div>
|
||
<p>When a guard gets dropped, the current thread is automatically unpinned.</p>
|
||
<h2 id="pointers-on-the-stack"><a class="doc-anchor" href="#pointers-on-the-stack">§</a>Pointers on the stack</h2>
|
||
<p>Having a guard allows us to create pointers on the stack to heap-allocated objects.
|
||
For example:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch::{<span class="self">self </span><span class="kw">as </span>epoch, Atomic};
|
||
<span class="kw">use </span>std::sync::atomic::Ordering::SeqCst;
|
||
|
||
<span class="comment">// Create a heap-allocated number.
|
||
</span><span class="kw">let </span>a = Atomic::new(<span class="number">777</span>);
|
||
|
||
<span class="comment">// Pin the current thread.
|
||
</span><span class="kw">let </span>guard = <span class="kw-2">&</span>epoch::pin();
|
||
|
||
<span class="comment">// Load the heap-allocated object and create pointer `p` on the stack.
|
||
</span><span class="kw">let </span>p = a.load(SeqCst, guard);
|
||
|
||
<span class="comment">// Dereference the pointer and print the value:
|
||
</span><span class="kw">if let </span><span class="prelude-val">Some</span>(num) = <span class="kw">unsafe </span>{ p.as_ref() } {
|
||
<span class="macro">println!</span>(<span class="string">"The number is {}."</span>, num);
|
||
}</code></pre></div><h2 id="multiple-guards"><a class="doc-anchor" href="#multiple-guards">§</a>Multiple guards</h2>
|
||
<p>Pinning is reentrant and it is perfectly legal to create multiple guards. In that case, the
|
||
thread will actually be pinned only when the first guard is created and unpinned when the last
|
||
one is dropped:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch <span class="kw">as </span>epoch;
|
||
|
||
<span class="kw">let </span>guard1 = epoch::pin();
|
||
<span class="kw">let </span>guard2 = epoch::pin();
|
||
<span class="macro">assert!</span>(epoch::is_pinned());
|
||
drop(guard1);
|
||
<span class="macro">assert!</span>(epoch::is_pinned());
|
||
drop(guard2);
|
||
<span class="macro">assert!</span>(!epoch::is_pinned());</code></pre></div></div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Guard" class="impl"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#73-409">Source</a><a href="#impl-Guard" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.defer" class="method"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#89-97">Source</a><h4 class="code-header">pub fn <a href="#method.defer" class="fn">defer</a><F, R>(&self, f: F)<div class="where">where
|
||
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -> R + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + 'static,</div></h4></section></summary><div class="docblock"><p>Stores a function so that it can be executed at some point after all currently pinned
|
||
threads get unpinned.</p>
|
||
<p>This method first stores <code>f</code> into the thread-local (or handle-local) cache. If this cache
|
||
becomes full, some functions are moved into the global cache. At the same time, some
|
||
functions from both local and global caches may get executed in order to incrementally
|
||
clean up the caches as they fill up.</p>
|
||
<p>There is no guarantee when exactly <code>f</code> will be executed. The only guarantee is that it
|
||
won’t be executed until all currently pinned threads get unpinned. In theory, <code>f</code> might
|
||
never run, but the epoch-based garbage collection will make an effort to execute it
|
||
reasonably soon.</p>
|
||
<p>If this method is called from an <a href="fn.unprotected.html" title="fn crossbeam_epoch::unprotected"><code>unprotected</code></a> guard, the function will simply be
|
||
executed immediately.</p>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.defer_unchecked" class="method"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#188-197">Source</a><h4 class="code-header">pub unsafe fn <a href="#method.defer_unchecked" class="fn">defer_unchecked</a><F, R>(&self, f: F)<div class="where">where
|
||
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -> R,</div></h4></section></summary><div class="docblock"><p>Stores a function so that it can be executed at some point after all currently pinned
|
||
threads get unpinned.</p>
|
||
<p>This method first stores <code>f</code> into the thread-local (or handle-local) cache. If this cache
|
||
becomes full, some functions are moved into the global cache. At the same time, some
|
||
functions from both local and global caches may get executed in order to incrementally
|
||
clean up the caches as they fill up.</p>
|
||
<p>There is no guarantee when exactly <code>f</code> will be executed. The only guarantee is that it
|
||
won’t be executed until all currently pinned threads get unpinned. In theory, <code>f</code> might
|
||
never run, but the epoch-based garbage collection will make an effort to execute it
|
||
reasonably soon.</p>
|
||
<p>If this method is called from an <a href="fn.unprotected.html" title="fn crossbeam_epoch::unprotected"><code>unprotected</code></a> guard, the function will simply be
|
||
executed immediately.</p>
|
||
<h5 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h5>
|
||
<p>The given function must not hold reference onto the stack. It is highly recommended that
|
||
the passed function is <strong>always</strong> marked with <code>move</code> in order to prevent accidental
|
||
borrows.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch <span class="kw">as </span>epoch;
|
||
|
||
<span class="kw">let </span>guard = <span class="kw-2">&</span>epoch::pin();
|
||
<span class="kw">let </span>message = <span class="string">"Hello!"</span>;
|
||
<span class="kw">unsafe </span>{
|
||
<span class="comment">// ALWAYS use `move` when sending a closure into `defer_unchecked`.
|
||
</span>guard.defer_unchecked(<span class="kw">move </span>|| {
|
||
<span class="macro">println!</span>(<span class="string">"{}"</span>, message);
|
||
});
|
||
}</code></pre></div>
|
||
<p>Apart from that, keep in mind that another thread may execute <code>f</code>, so anything accessed by
|
||
the closure must be <code>Send</code>.</p>
|
||
<p>We intentionally didn’t require <code>F: Send</code>, because Rust’s type systems usually cannot prove
|
||
<code>F: Send</code> for typical use cases. For example, consider the following code snippet, which
|
||
exemplifies the typical use case of deferring the deallocation of a shared reference:</p>
|
||
|
||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">let </span>shared = Owned::new(<span class="number">7i32</span>).into_shared(guard);
|
||
guard.defer_unchecked(<span class="kw">move </span>|| shared.into_owned()); <span class="comment">// `Shared` is not `Send`!</span></code></pre></div>
|
||
<p>While <code>Shared</code> is not <code>Send</code>, it’s safe for another thread to call the deferred function,
|
||
because it’s called only after the grace period and <code>shared</code> is no longer shared with other
|
||
threads. But we don’t expect type systems to prove this.</p>
|
||
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
|
||
<p>When a heap-allocated object in a data structure becomes unreachable, it has to be
|
||
deallocated. However, the current thread and other threads may be still holding references
|
||
on the stack to that same object. Therefore it cannot be deallocated before those references
|
||
get dropped. This method can defer deallocation until all those threads get unpinned and
|
||
consequently drop all their references on the stack.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch::{<span class="self">self </span><span class="kw">as </span>epoch, Atomic, Owned};
|
||
<span class="kw">use </span>std::sync::atomic::Ordering::SeqCst;
|
||
|
||
<span class="kw">let </span>a = Atomic::new(<span class="string">"foo"</span>);
|
||
|
||
<span class="comment">// Now suppose that `a` is shared among multiple threads and concurrently
|
||
// accessed and modified...
|
||
|
||
// Pin the current thread.
|
||
</span><span class="kw">let </span>guard = <span class="kw-2">&</span>epoch::pin();
|
||
|
||
<span class="comment">// Steal the object currently stored in `a` and swap it with another one.
|
||
</span><span class="kw">let </span>p = a.swap(Owned::new(<span class="string">"bar"</span>).into_shared(guard), SeqCst, guard);
|
||
|
||
<span class="kw">if </span>!p.is_null() {
|
||
<span class="comment">// The object `p` is pointing to is now unreachable.
|
||
// Defer its deallocation until all currently pinned threads get unpinned.
|
||
</span><span class="kw">unsafe </span>{
|
||
<span class="comment">// ALWAYS use `move` when sending a closure into `defer_unchecked`.
|
||
</span>guard.defer_unchecked(<span class="kw">move </span>|| {
|
||
<span class="macro">println!</span>(<span class="string">"{} is now being deallocated."</span>, p.deref());
|
||
<span class="comment">// Now we have unique access to the object pointed to by `p` and can turn it
|
||
// into an `Owned`. Dropping the `Owned` will deallocate the object.
|
||
</span>drop(p.into_owned());
|
||
});
|
||
}
|
||
}</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.defer_destroy" class="method"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#268-270">Source</a><h4 class="code-header">pub unsafe fn <a href="#method.defer_destroy" class="fn">defer_destroy</a><T>(&self, ptr: <a class="struct" href="struct.Shared.html" title="struct crossbeam_epoch::Shared">Shared</a><'_, T>)</h4></section></summary><div class="docblock"><p>Stores a destructor for an object so that it can be deallocated and dropped at some point
|
||
after all currently pinned threads get unpinned.</p>
|
||
<p>This method first stores the destructor into the thread-local (or handle-local) cache. If
|
||
this cache becomes full, some destructors are moved into the global cache. At the same
|
||
time, some destructors from both local and global caches may get executed in order to
|
||
incrementally clean up the caches as they fill up.</p>
|
||
<p>There is no guarantee when exactly the destructor will be executed. The only guarantee is
|
||
that it won’t be executed until all currently pinned threads get unpinned. In theory, the
|
||
destructor might never run, but the epoch-based garbage collection will make an effort to
|
||
execute it reasonably soon.</p>
|
||
<p>If this method is called from an <a href="fn.unprotected.html" title="fn crossbeam_epoch::unprotected"><code>unprotected</code></a> guard, the destructor will simply be
|
||
executed immediately.</p>
|
||
<h5 id="safety-1"><a class="doc-anchor" href="#safety-1">§</a>Safety</h5>
|
||
<p>The object must not be reachable by other threads anymore, otherwise it might be still in
|
||
use when the destructor runs.</p>
|
||
<p>Apart from that, keep in mind that another thread may execute the destructor, so the object
|
||
must be sendable to other threads.</p>
|
||
<p>We intentionally didn’t require <code>T: Send</code>, because Rust’s type systems usually cannot prove
|
||
<code>T: Send</code> for typical use cases. For example, consider the following code snippet, which
|
||
exemplifies the typical use case of deferring the deallocation of a shared reference:</p>
|
||
|
||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">let </span>shared = Owned::new(<span class="number">7i32</span>).into_shared(guard);
|
||
guard.defer_destroy(shared); <span class="comment">// `Shared` is not `Send`!</span></code></pre></div>
|
||
<p>While <code>Shared</code> is not <code>Send</code>, it’s safe for another thread to call the destructor, because
|
||
it’s called only after the grace period and <code>shared</code> is no longer shared with other
|
||
threads. But we don’t expect type systems to prove this.</p>
|
||
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
||
<p>When a heap-allocated object in a data structure becomes unreachable, it has to be
|
||
deallocated. However, the current thread and other threads may be still holding references
|
||
on the stack to that same object. Therefore it cannot be deallocated before those references
|
||
get dropped. This method can defer deallocation until all those threads get unpinned and
|
||
consequently drop all their references on the stack.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch::{<span class="self">self </span><span class="kw">as </span>epoch, Atomic, Owned};
|
||
<span class="kw">use </span>std::sync::atomic::Ordering::SeqCst;
|
||
|
||
<span class="kw">let </span>a = Atomic::new(<span class="string">"foo"</span>);
|
||
|
||
<span class="comment">// Now suppose that `a` is shared among multiple threads and concurrently
|
||
// accessed and modified...
|
||
|
||
// Pin the current thread.
|
||
</span><span class="kw">let </span>guard = <span class="kw-2">&</span>epoch::pin();
|
||
|
||
<span class="comment">// Steal the object currently stored in `a` and swap it with another one.
|
||
</span><span class="kw">let </span>p = a.swap(Owned::new(<span class="string">"bar"</span>).into_shared(guard), SeqCst, guard);
|
||
|
||
<span class="kw">if </span>!p.is_null() {
|
||
<span class="comment">// The object `p` is pointing to is now unreachable.
|
||
// Defer its deallocation until all currently pinned threads get unpinned.
|
||
</span><span class="kw">unsafe </span>{
|
||
guard.defer_destroy(p);
|
||
}
|
||
}</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.flush" class="method"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#292-296">Source</a><h4 class="code-header">pub fn <a href="#method.flush" class="fn">flush</a>(&self)</h4></section></summary><div class="docblock"><p>Clears up the thread-local cache of deferred functions by executing them or moving into the
|
||
global cache.</p>
|
||
<p>Call this method after deferring execution of a function if you want to get it executed as
|
||
soon as possible. Flushing will make sure it is residing in in the global cache, so that
|
||
any thread has a chance of taking the function and executing it.</p>
|
||
<p>If this method is called from an <a href="fn.unprotected.html" title="fn crossbeam_epoch::unprotected"><code>unprotected</code></a> guard, it is a no-op (nothing happens).</p>
|
||
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch <span class="kw">as </span>epoch;
|
||
|
||
<span class="kw">let </span>guard = <span class="kw-2">&</span>epoch::pin();
|
||
guard.defer(<span class="kw">move </span>|| {
|
||
<span class="macro">println!</span>(<span class="string">"This better be printed as soon as possible!"</span>);
|
||
});
|
||
guard.flush();</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.repin" class="method"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#326-330">Source</a><h4 class="code-header">pub fn <a href="#method.repin" class="fn">repin</a>(&mut self)</h4></section></summary><div class="docblock"><p>Unpins and then immediately re-pins the thread.</p>
|
||
<p>This method is useful when you don’t want delay the advancement of the global epoch by
|
||
holding an old epoch. For safety, you should not maintain any guard-based reference across
|
||
the call (the latter is enforced by <code>&mut self</code>). The thread will only be repinned if this
|
||
is the only active guard for the current thread.</p>
|
||
<p>If this method is called from an <a href="fn.unprotected.html" title="fn crossbeam_epoch::unprotected"><code>unprotected</code></a> guard, then the call will be just no-op.</p>
|
||
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch::{<span class="self">self </span><span class="kw">as </span>epoch, Atomic};
|
||
<span class="kw">use </span>std::sync::atomic::Ordering::SeqCst;
|
||
|
||
<span class="kw">let </span>a = Atomic::new(<span class="number">777</span>);
|
||
<span class="kw">let </span><span class="kw-2">mut </span>guard = epoch::pin();
|
||
{
|
||
<span class="kw">let </span>p = a.load(SeqCst, <span class="kw-2">&</span>guard);
|
||
<span class="macro">assert_eq!</span>(<span class="kw">unsafe </span>{ p.as_ref() }, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">777</span>));
|
||
}
|
||
guard.repin();
|
||
{
|
||
<span class="kw">let </span>p = a.load(SeqCst, <span class="kw-2">&</span>guard);
|
||
<span class="macro">assert_eq!</span>(<span class="kw">unsafe </span>{ p.as_ref() }, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">777</span>));
|
||
}</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.repin_after" class="method"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#363-388">Source</a><h4 class="code-header">pub fn <a href="#method.repin_after" class="fn">repin_after</a><F, R>(&mut self, f: F) -> R<div class="where">where
|
||
F: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -> R,</div></h4></section></summary><div class="docblock"><p>Temporarily unpins the thread, executes the given function and then re-pins the thread.</p>
|
||
<p>This method is useful when you need to perform a long-running operation (e.g. sleeping)
|
||
and don’t need to maintain any guard-based reference across the call (the latter is enforced
|
||
by <code>&mut self</code>). The thread will only be unpinned if this is the only active guard for the
|
||
current thread.</p>
|
||
<p>If this method is called from an <a href="fn.unprotected.html" title="fn crossbeam_epoch::unprotected"><code>unprotected</code></a> guard, then the passed function is called
|
||
directly without unpinning the thread.</p>
|
||
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch::{<span class="self">self </span><span class="kw">as </span>epoch, Atomic};
|
||
<span class="kw">use </span>std::sync::atomic::Ordering::SeqCst;
|
||
<span class="kw">use </span>std::thread;
|
||
<span class="kw">use </span>std::time::Duration;
|
||
|
||
<span class="kw">let </span>a = Atomic::new(<span class="number">777</span>);
|
||
<span class="kw">let </span><span class="kw-2">mut </span>guard = epoch::pin();
|
||
{
|
||
<span class="kw">let </span>p = a.load(SeqCst, <span class="kw-2">&</span>guard);
|
||
<span class="macro">assert_eq!</span>(<span class="kw">unsafe </span>{ p.as_ref() }, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">777</span>));
|
||
}
|
||
guard.repin_after(|| thread::sleep(Duration::from_millis(<span class="number">50</span>)));
|
||
{
|
||
<span class="kw">let </span>p = a.load(SeqCst, <span class="kw-2">&</span>guard);
|
||
<span class="macro">assert_eq!</span>(<span class="kw">unsafe </span>{ p.as_ref() }, <span class="prelude-val">Some</span>(<span class="kw-2">&</span><span class="number">777</span>));
|
||
}</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.collector" class="method"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#406-408">Source</a><h4 class="code-header">pub fn <a href="#method.collector" class="fn">collector</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="struct.Collector.html" title="struct crossbeam_epoch::Collector">Collector</a>></h4></section></summary><div class="docblock"><p>Returns the <code>Collector</code> associated with this guard.</p>
|
||
<p>This method is useful when you need to ensure that all guards used with
|
||
a data structure come from the same collector.</p>
|
||
<p>If this method is called from an <a href="fn.unprotected.html" title="fn crossbeam_epoch::unprotected"><code>unprotected</code></a> guard, then <code>None</code> is returned.</p>
|
||
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>crossbeam_epoch <span class="kw">as </span>epoch;
|
||
|
||
<span class="kw">let </span>guard1 = epoch::pin();
|
||
<span class="kw">let </span>guard2 = epoch::pin();
|
||
<span class="macro">assert!</span>(guard1.collector() == guard2.collector());</code></pre></div></div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Guard" class="impl"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#420-424">Source</a><a href="#impl-Debug-for-Guard" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#421-423">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.93.1/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Drop-for-Guard" class="impl"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#411-418">Source</a><a href="#impl-Drop-for-Guard" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.drop" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/guard.rs.html#413-417">Source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/ops/drop/trait.Drop.html#tymethod.drop" class="fn">drop</a>(&mut self)</h4></section></summary><div class='docblock'>Executes the destructor for this type. <a href="https://doc.rust-lang.org/1.93.1/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Guard" class="impl"><a href="#impl-Freeze-for-Guard" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a></h3></section><section id="impl-RefUnwindSafe-for-Guard" class="impl"><a href="#impl-RefUnwindSafe-for-Guard" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a></h3></section><section id="impl-Send-for-Guard" class="impl"><a href="#impl-Send-for-Guard" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a></h3></section><section id="impl-Sync-for-Guard" class="impl"><a href="#impl-Sync-for-Guard" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a></h3></section><section id="impl-Unpin-for-Guard" class="impl"><a href="#impl-Unpin-for-Guard" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a></h3></section><section id="impl-UnwindSafe-for-Guard" class="impl"><a href="#impl-UnwindSafe-for-Guard" class="anchor">§</a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Guard.html" title="struct crossbeam_epoch::Guard">Guard</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#212">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#214">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#221">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/borrow.rs.html#222">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#785">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#788">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#767-769">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#777">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||
<p>That is, this conversion is whatever the implementation of
|
||
<code><a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Pointable-for-T" class="impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#194-214">Source</a><a href="#impl-Pointable-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="trait.Pointable.html" title="trait crossbeam_epoch::Pointable">Pointable</a> for T</h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedconstant.ALIGN" class="associatedconstant trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#195">Source</a><a href="#associatedconstant.ALIGN" class="anchor">§</a><h4 class="code-header">const <a href="trait.Pointable.html#associatedconstant.ALIGN" class="constant">ALIGN</a>: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a> = const ALIGN: usize = mem::align_of::<T>();</h4></section></summary><div class='docblock'>The alignment of pointer.</div></details><details class="toggle" open><summary><section id="associatedtype.Init" class="associatedtype trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#197">Source</a><a href="#associatedtype.Init" class="anchor">§</a><h4 class="code-header">type <a href="trait.Pointable.html#associatedtype.Init" class="associatedtype">Init</a> = T</h4></section></summary><div class='docblock'>The type for initializers.</div></details><details class="toggle method-toggle" open><summary><section id="method.init" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#199-201">Source</a><a href="#method.init" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="trait.Pointable.html#tymethod.init" class="fn">init</a>(init: <T as <a class="trait" href="trait.Pointable.html" title="trait crossbeam_epoch::Pointable">Pointable</a>>::<a class="associatedtype" href="trait.Pointable.html#associatedtype.Init" title="type crossbeam_epoch::Pointable::Init">Init</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a></h4></section></summary><div class='docblock'>Initializes a with the given initializer. <a href="trait.Pointable.html#tymethod.init">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.deref" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#203-205">Source</a><a href="#method.deref" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="trait.Pointable.html#tymethod.deref" class="fn">deref</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&'a T</a></h4></section></summary><div class='docblock'>Dereferences the given pointer. <a href="trait.Pointable.html#tymethod.deref">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.deref_mut" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#207-209">Source</a><a href="#method.deref_mut" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="trait.Pointable.html#tymethod.deref_mut" class="fn">deref_mut</a><'a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&'a mut T</a></h4></section></summary><div class='docblock'>Mutably dereferences the given pointer. <a href="trait.Pointable.html#tymethod.deref_mut">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.drop-1" class="method trait-impl"><a class="src rightside" href="../src/crossbeam_epoch/atomic.rs.html#211-213">Source</a><a href="#method.drop-1" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="trait.Pointable.html#tymethod.drop" class="fn">drop</a>(ptr: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.usize.html">usize</a>)</h4></section></summary><div class='docblock'>Drops the object pointed to by the given pointer. <a href="trait.Pointable.html#tymethod.drop">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#827-829">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#831">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#834">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#811-813">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#815">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#818">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html> |