92 lines
38 KiB
HTML
92 lines
38 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 write-once primitive similar to `std::sync::OnceLock<T>`."><title>GILOnceCell in pyo3::sync - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-46132b98.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="pyo3" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.1 (4eb161250 2025-03-15)" data-channel="1.85.1" data-search-js="search-75f5ac3e.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../pyo3/index.html">pyo3</a><span class="version">0.24.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">GILOnce<wbr>Cell</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#re-entrant-initialization" title="Re-entrant initialization">Re-entrant initialization</a></li><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.clone_ref" title="clone_ref">clone_ref</a></li><li><a href="#method.get" title="get">get</a></li><li><a href="#method.get_mut" title="get_mut">get_mut</a></li><li><a href="#method.get_or_init" title="get_or_init">get_or_init</a></li><li><a href="#method.get_or_try_init" title="get_or_try_init">get_or_try_init</a></li><li><a href="#method.import" title="import">import</a></li><li><a href="#method.into_inner" title="into_inner">into_inner</a></li><li><a href="#method.new" title="new">new</a></li><li><a href="#method.set" title="set">set</a></li><li><a href="#method.take" title="take">take</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Default-for-GILOnceCell%3CT%3E" title="Default">Default</a></li><li><a href="#impl-Drop-for-GILOnceCell%3CT%3E" title="Drop">Drop</a></li><li><a href="#impl-Send-for-GILOnceCell%3CT%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-GILOnceCell%3CT%3E" title="Sync">Sync</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-GILOnceCell%3CT%3E" title="!Freeze">!Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-GILOnceCell%3CT%3E" title="!RefUnwindSafe">!RefUnwindSafe</a></li><li><a href="#impl-Unpin-for-GILOnceCell%3CT%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-GILOnceCell%3CT%3E" title="UnwindSafe">UnwindSafe</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-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><li><a href="#impl-Ungil-for-T" title="Ungil">Ungil</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In pyo3::<wbr>sync</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">pyo3</a>::<wbr><a href="index.html">sync</a></span><h1>Struct <span class="struct">GILOnceCell</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/pyo3/sync.rs.html#122-147">Source</a> </span></div><pre class="rust item-decl"><code>pub struct GILOnceCell<T> { <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 write-once primitive similar to <a href="https://doc.rust-lang.org/1.85.1/std/sync/once_lock/struct.OnceLock.html" title="struct std::sync::once_lock::OnceLock"><code>std::sync::OnceLock<T></code></a>.</p>
|
|
<p>Unlike <code>OnceLock<T></code> which blocks threads to achieve thread safety, <code>GilOnceCell<T></code>
|
|
allows calls to <a href="struct.GILOnceCell.html#method.get_or_init" title="method pyo3::sync::GILOnceCell::get_or_init"><code>get_or_init</code></a> and
|
|
<a href="struct.GILOnceCell.html#method.get_or_try_init" title="method pyo3::sync::GILOnceCell::get_or_try_init"><code>get_or_try_init</code></a> to race to create an initialized value.
|
|
(It is still guaranteed that only one thread will ever write to the cell.)</p>
|
|
<p>On Python versions that run with the Global Interpreter Lock (GIL), this helps to avoid
|
|
deadlocks between initialization and the GIL. For an example of such a deadlock, see
|
|
<a href="https://pyo3.rs/v0.24.1/faq.html#im-experiencing-deadlocks-using-pyo3-with-stdsynconcelock-stdsynclazylock-lazy_static-and-once_cell">the FAQ section</a>
|
|
of the guide.</p>
|
|
<p>Note that because the GIL blocks concurrent execution, in practice the means that
|
|
<a href="struct.GILOnceCell.html#method.get_or_init" title="method pyo3::sync::GILOnceCell::get_or_init"><code>get_or_init</code></a> and
|
|
<a href="struct.GILOnceCell.html#method.get_or_try_init" title="method pyo3::sync::GILOnceCell::get_or_try_init"><code>get_or_try_init</code></a> may race if the initialization
|
|
function leads to the GIL being released and a thread context switch. This can
|
|
happen when importing or calling any Python code, as long as it releases the
|
|
GIL at some point. On free-threaded Python without any GIL, the race is
|
|
more likely since there is no GIL to prevent races. In the future, PyO3 may change
|
|
the semantics of GILOnceCell to behave more like the GIL build in the future.</p>
|
|
<h2 id="re-entrant-initialization"><a class="doc-anchor" href="#re-entrant-initialization">§</a>Re-entrant initialization</h2>
|
|
<p><a href="struct.GILOnceCell.html#method.get_or_init" title="method pyo3::sync::GILOnceCell::get_or_init"><code>get_or_init</code></a> and
|
|
<a href="struct.GILOnceCell.html#method.get_or_try_init" title="method pyo3::sync::GILOnceCell::get_or_try_init"><code>get_or_try_init</code></a> do not protect against infinite recursion
|
|
from reentrant initialization.</p>
|
|
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
|
<p>The following example shows how to use <code>GILOnceCell</code> to share a reference to a Python list
|
|
between threads:</p>
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::sync::GILOnceCell;
|
|
<span class="kw">use </span>pyo3::prelude::<span class="kw-2">*</span>;
|
|
<span class="kw">use </span>pyo3::types::PyList;
|
|
|
|
<span class="kw">static </span>LIST_CELL: GILOnceCell<Py<PyList>> = GILOnceCell::new();
|
|
|
|
<span class="kw">pub fn </span>get_shared_list(py: Python<<span class="lifetime">'_</span>>) -> <span class="kw-2">&</span>Bound<<span class="lifetime">'_</span>, PyList> {
|
|
LIST_CELL
|
|
.get_or_init(py, || PyList::empty(py).unbind())
|
|
.bind(py)
|
|
}</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-GILOnceCell%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/sync.rs.html#161-292">Source</a><a href="#impl-GILOnceCell%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#163-169">Source</a><h4 class="code-header">pub const fn <a href="#method.new" class="fn">new</a>() -> Self</h4></section></summary><div class="docblock"><p>Create a <code>GILOnceCell</code> which does not yet contain a value.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#173-180">Source</a><h4 class="code-header">pub fn <a href="#method.get" class="fn">get</a>(&self, _py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a><'_>) -> <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.reference.html">&T</a>></h4></section></summary><div class="docblock"><p>Get a reference to the contained value, or <code>None</code> if the cell has not yet been written.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_or_init" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#187-198">Source</a><h4 class="code-header">pub fn <a href="#method.get_or_init" class="fn">get_or_init</a><F>(&self, py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a><'_>, f: F) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.reference.html">&T</a><div class="where">where
|
|
F: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -> T,</div></h4></section></summary><div class="docblock"><p>Get a reference to the contained value, initializing it if needed using the provided
|
|
closure.</p>
|
|
<p>See the type-level documentation for detail on re-entrancy and concurrent initialization.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_or_try_init" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#205-214">Source</a><h4 class="code-header">pub fn <a href="#method.get_or_try_init" class="fn">get_or_try_init</a><F, E>(&self, py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a><'_>, f: F) -> <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.reference.html">&T</a>, E><div class="where">where
|
|
F: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -> <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, E>,</div></h4></section></summary><div class="docblock"><p>Like <code>get_or_init</code>, but accepts a fallible initialization function. If it fails, the cell
|
|
is left uninitialized.</p>
|
|
<p>See the type-level documentation for detail on re-entrancy and concurrent initialization.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.get_mut" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#236-243">Source</a><h4 class="code-header">pub fn <a href="#method.get_mut" class="fn">get_mut</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.reference.html">&mut T</a>></h4></section></summary><div class="docblock"><p>Get the contents of the cell mutably. This is only possible if the reference to the cell is
|
|
unique.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.set" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#249-268">Source</a><h4 class="code-header">pub fn <a href="#method.set" class="fn">set</a>(&self, _py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a><'_>, value: T) -> <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>, T></h4></section></summary><div class="docblock"><p>Set the value in the cell.</p>
|
|
<p>If the cell has already been written, <code>Err(value)</code> will be returned containing the new
|
|
value which was not written.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.take" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#273-284">Source</a><h4 class="code-header">pub fn <a href="#method.take" class="fn">take</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T></h4></section></summary><div class="docblock"><p>Takes the value out of the cell, moving it back to an uninitialized state.</p>
|
|
<p>Has no effect and returns None if the cell has not yet been written.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_inner" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#289-291">Source</a><h4 class="code-header">pub fn <a href="#method.into_inner" class="fn">into_inner</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.85.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T></h4></section></summary><div class="docblock"><p>Consumes the cell, returning the wrapped value.</p>
|
|
<p>Returns None if the cell has not yet been written.</p>
|
|
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-GILOnceCell%3CPy%3CT%3E%3E" class="impl"><a class="src rightside" href="../../src/pyo3/sync.rs.html#294-309">Source</a><a href="#impl-GILOnceCell%3CPy%3CT%3E%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><<a class="struct" href="../struct.Py.html" title="struct pyo3::Py">Py</a><T>></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone_ref" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#298-308">Source</a><h4 class="code-header">pub fn <a href="#method.clone_ref" class="fn">clone_ref</a>(&self, py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a><'_>) -> Self</h4></section></summary><div class="docblock"><p>Creates a new cell that contains a new Python reference to the same contained object.</p>
|
|
<p>Returns an uninitialized cell if <code>self</code> has not yet been initialized.</p>
|
|
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-GILOnceCell%3CPy%3CT%3E%3E-1" class="impl"><a class="src rightside" href="../../src/pyo3/sync.rs.html#311-361">Source</a><a href="#impl-GILOnceCell%3CPy%3CT%3E%3E-1" class="anchor">§</a><h3 class="code-header">impl<T> <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><<a class="struct" href="../struct.Py.html" title="struct pyo3::Py">Py</a><T>><div class="where">where
|
|
T: <a class="trait" href="../type_object/trait.PyTypeCheck.html" title="trait pyo3::type_object::PyTypeCheck">PyTypeCheck</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.import" class="method"><a class="src rightside" href="../../src/pyo3/sync.rs.html#346-360">Source</a><h4 class="code-header">pub fn <a href="#method.import" class="fn">import</a><'py>(
|
|
&self,
|
|
py: <a class="struct" href="../marker/struct.Python.html" title="struct pyo3::marker::Python">Python</a><'py>,
|
|
module_name: &<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.str.html">str</a>,
|
|
attr_name: &<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.str.html">str</a>,
|
|
) -> <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a><&<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a><'py, T>></h4></section></summary><div class="docblock"><p>Get a reference to the contained Python type, initializing the cell if needed.</p>
|
|
<p>This is a shorthand method for <code>get_or_init</code> which imports the type from Python on init.</p>
|
|
<h5 id="example-using-giloncecell-to-store-a-class-in-a-static-variable"><a class="doc-anchor" href="#example-using-giloncecell-to-store-a-class-in-a-static-variable">§</a>Example: Using <code>GILOnceCell</code> to store a class in a static variable.</h5>
|
|
<p><code>GILOnceCell</code> can be used to avoid importing a class multiple times:</p>
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[pyfunction]
|
|
</span><span class="kw">fn </span>create_ordered_dict<<span class="lifetime">'py</span>>(py: Python<<span class="lifetime">'py</span>>, dict: Bound<<span class="lifetime">'py</span>, PyDict>) -> PyResult<Bound<<span class="lifetime">'py</span>, PyAny>> {
|
|
<span class="comment">// Even if this function is called multiple times,
|
|
// the `OrderedDict` class will be imported only once.
|
|
</span><span class="kw">static </span>ORDERED_DICT: GILOnceCell<Py<PyType>> = GILOnceCell::new();
|
|
ORDERED_DICT
|
|
.import(py, <span class="string">"collections"</span>, <span class="string">"OrderedDict"</span>)<span class="question-mark">?
|
|
</span>.call1((dict,))
|
|
}
|
|
</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-Default-for-GILOnceCell%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/sync.rs.html#149-153">Source</a><a href="#impl-Default-for-GILOnceCell%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a> for <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><T></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.default" class="method trait-impl"><a class="src rightside" href="../../src/pyo3/sync.rs.html#150-152">Source</a><a href="#method.default" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/default/trait.Default.html#tymethod.default" class="fn">default</a>() -> Self</h4></section></summary><div class='docblock'>Returns the “default value” for a type. <a href="https://doc.rust-lang.org/1.85.1/core/default/trait.Default.html#tymethod.default">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Drop-for-GILOnceCell%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/sync.rs.html#363-370">Source</a><a href="#impl-Drop-for-GILOnceCell%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/ops/drop/trait.Drop.html" title="trait core::ops::drop::Drop">Drop</a> for <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><T></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/pyo3/sync.rs.html#364-369">Source</a><a href="#method.drop" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.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.85.1/core/ops/drop/trait.Drop.html#tymethod.drop">Read more</a></div></details></div></details><section id="impl-Send-for-GILOnceCell%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/sync.rs.html#159">Source</a><a href="#impl-Send-for-GILOnceCell%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>> <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><T></h3></section><section id="impl-Sync-for-GILOnceCell%3CT%3E" class="impl"><a class="src rightside" href="../../src/pyo3/sync.rs.html#158">Source</a><a href="#impl-Sync-for-GILOnceCell%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>> <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><T></h3></section></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-GILOnceCell%3CT%3E" class="impl"><a href="#impl-Freeze-for-GILOnceCell%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> !<a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><T></h3></section><section id="impl-RefUnwindSafe-for-GILOnceCell%3CT%3E" class="impl"><a href="#impl-RefUnwindSafe-for-GILOnceCell%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> !<a class="trait" href="https://doc.rust-lang.org/1.85.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><T></h3></section><section id="impl-Unpin-for-GILOnceCell%3CT%3E" class="impl"><a href="#impl-Unpin-for-GILOnceCell%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><T><div class="where">where
|
|
T: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h3></section><section id="impl-UnwindSafe-for-GILOnceCell%3CT%3E" class="impl"><a href="#impl-UnwindSafe-for-GILOnceCell%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.GILOnceCell.html" title="struct pyo3::sync::GILOnceCell">GILOnceCell</a><T><div class="where">where
|
|
T: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a>,</div></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.85.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.85.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.85.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.85.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.85.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.85.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.85.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.85.1/src/core/borrow.rs.html#209">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.85.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.85.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.85.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.85.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.85.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.85.1/src/core/borrow.rs.html#217">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.85.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.85.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.85.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.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.85.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.85.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.85.1/src/core/convert/mod.rs.html#767">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.85.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.85.1/src/core/convert/mod.rs.html#770">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.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.85.1/src/core/convert/mod.rs.html#750-752">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.85.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.85.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.85.1/src/core/convert/mod.rs.html#760">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.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.85.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-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.85.1/src/core/convert/mod.rs.html#807-809">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.85.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.85.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.85.1/src/core/convert/mod.rs.html#811">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.85.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.85.1/src/core/convert/mod.rs.html#814">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.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.85.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.85.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.85.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.85.1/src/core/convert/mod.rs.html#792-794">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.85.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.85.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.85.1/src/core/convert/mod.rs.html#796">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.85.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.85.1/src/core/convert/mod.rs.html#799">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.85.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.85.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.85.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.85.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><section id="impl-Ungil-for-T" class="impl"><a class="src rightside" href="../../src/pyo3/marker.rs.html#194">Source</a><a href="#impl-Ungil-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="../marker/trait.Ungil.html" title="trait pyo3::marker::Ungil">Ungil</a> for T<div class="where">where
|
|
T: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,</div></h3></section></div></section></div></main></body></html> |