263 lines
102 KiB
HTML
263 lines
102 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="`PyCell` is the container type for `PyClass`."><meta name="keywords" content="rust, rustlang, rust-lang, PyCell"><title>pyo3::pycell::PyCell - 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="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><script src="../../crates.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><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" role="button">☰</div><a href='../../pyo3/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Struct PyCell</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.borrow">borrow</a><a href="#method.borrow_mut">borrow_mut</a><a href="#method.new">new</a><a href="#method.replace">replace</a><a href="#method.replace_with">replace_with</a><a href="#method.swap">swap</a><a href="#method.try_borrow">try_borrow</a><a href="#method.try_borrow_mut">try_borrow_mut</a><a href="#method.try_borrow_unguarded">try_borrow_unguarded</a></div><a class="sidebar-title" href="#deref-methods">Methods from Deref<Target=PyAny></a><div class="sidebar-links"><a href="#method.call">call</a><a href="#method.call0">call0</a><a href="#method.call1">call1</a><a href="#method.call_method">call_method</a><a href="#method.call_method0">call_method0</a><a href="#method.call_method1">call_method1</a><a href="#method.cast_as">cast_as</a><a href="#method.compare">compare</a><a href="#method.del_item">del_item</a><a href="#method.delattr">delattr</a><a href="#method.dir">dir</a><a href="#method.downcast">downcast</a><a href="#method.extract">extract</a><a href="#method.get_item">get_item</a><a href="#method.get_refcnt">get_refcnt</a><a href="#method.get_type">get_type</a><a href="#method.get_type_ptr">get_type_ptr</a><a href="#method.getattr">getattr</a><a href="#method.hasattr">hasattr</a><a href="#method.hash">hash</a><a href="#method.is_callable">is_callable</a><a href="#method.is_empty">is_empty</a><a href="#method.is_instance">is_instance</a><a href="#method.is_none">is_none</a><a href="#method.is_true">is_true</a><a href="#method.iter">iter</a><a href="#method.len">len</a><a href="#method.repr">repr</a><a href="#method.rich_compare">rich_compare</a><a href="#method.set_item">set_item</a><a href="#method.setattr">setattr</a><a href="#method.str">str</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsPyPointer">AsPyPointer</a><a href="#impl-AsRef%3CPyAny%3E">AsRef<PyAny></a><a href="#impl-Debug">Debug</a><a href="#impl-Deref">Deref</a><a href="#impl-From%3C%26%27_%20PyCell%3CT%3E%3E">From<&'_ PyCell<T>></a><a href="#impl-FromPyObject%3C%27a%3E">FromPyObject<'a></a><a href="#impl-PyLayout%3CT%3E">PyLayout<T></a><a href="#impl-PyNativeType">PyNativeType</a><a href="#impl-PyTryFrom%3C%27v%3E">PyTryFrom<'v></a><a href="#impl-ToPyObject">ToPyObject</a><a href="#impl-TryFrom%3C%26%27a%20PyCell%3CT%3E%3E">TryFrom<&'a PyCell<T>></a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">!RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">!Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow<T></a><a href="#impl-BorrowMut%3CT%3E">BorrowMut<T></a><a href="#impl-From%3CT%3E">From<T></a><a href="#impl-FromPyPointer%3C%27p%3E">FromPyPointer<'p></a><a href="#impl-Into%3CU%3E">Into<U></a><a href="#impl-TryFrom%3CU%3E">TryFrom<U></a><a href="#impl-TryInto%3CU%3E">TryInto<U></a></div></div><p class="location"><a href="../index.html">pyo3</a>::<wbr><a href="index.html">pycell</a></p><div id="sidebar-vars" data-name="PyCell" data-ty="struct" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" height="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" height="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="../index.html">pyo3</a>::<wbr><a href="index.html">pycell</a>::<wbr><a class="struct" href="">PyCell</a></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../../src/pyo3/pycell.rs.html#162-169" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct"><span class="docblock attributes top-attr">#[repr(C)]</span>pub struct PyCell<T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> { /* fields omitted */ }</pre></div><div class="docblock"><p><code>PyCell</code> is the container type for <a href="../pyclass/trait.PyClass.html"><code>PyClass</code></a>.</p>
|
||
<p>From Python side, <code>PyCell<T></code> is the concrete layout of <code>T: PyClass</code> in the Python heap,
|
||
which means we can convert <code>*const PyClass<T></code> to <code>*mut ffi::PyObject</code>.</p>
|
||
<p>From Rust side, <code>PyCell<T></code> is the mutable container of <code>T</code>.
|
||
Since <code>PyCell<T: PyClass></code> is always on the Python heap, we don’t have the ownership of it.
|
||
Thus, to mutate the data behind <code>&PyCell<T></code> safely, we employ the
|
||
<a href="https://doc.rust-lang.org/book/ch15-05-interior-mutability.html">Interior Mutability Pattern</a>
|
||
like <a href="https://doc.rust-lang.org/std/cell/struct.RefCell.html">std::cell::RefCell</a>.</p>
|
||
<p><code>PyCell</code> implements <code>Deref<Target = PyAny></code>, so you can also call methods from <code>PyAny</code>
|
||
when you have a <code>PyCell<T></code>.</p>
|
||
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
||
<p>In most cases, <code>PyCell</code> is hidden behind <code>#[pymethods]</code>.
|
||
However, you can construct <code>&PyCell</code> directly to test your pyclass in Rust code.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="attribute">#[<span class="ident">pyclass</span>]</span>
|
||
<span class="kw">struct</span> <span class="ident">Book</span> {
|
||
<span class="attribute">#[<span class="ident">pyo3</span>(<span class="ident">get</span>)]</span>
|
||
<span class="ident">name</span>: <span class="kw-2">&</span><span class="lifetime">'static</span> <span class="ident">str</span>,
|
||
<span class="ident">author</span>: <span class="kw-2">&</span><span class="lifetime">'static</span> <span class="ident">str</span>,
|
||
}
|
||
<span class="kw">let</span> <span class="ident">gil</span> <span class="op">=</span> <span class="ident">Python</span>::<span class="ident">acquire_gil</span>();
|
||
<span class="kw">let</span> <span class="ident">py</span> <span class="op">=</span> <span class="ident">gil</span>.<span class="ident">python</span>();
|
||
<span class="kw">let</span> <span class="ident">book</span> <span class="op">=</span> <span class="ident">Book</span> {
|
||
<span class="ident">name</span>: <span class="string">"The Man in the High Castle"</span>,
|
||
<span class="ident">author</span>: <span class="string">"Philip Kindred Dick"</span>,
|
||
};
|
||
<span class="kw">let</span> <span class="ident">book_cell</span> <span class="op">=</span> <span class="ident">PyCell</span>::<span class="ident">new</span>(<span class="ident">py</span>, <span class="ident">book</span>).<span class="ident">unwrap</span>();
|
||
<span class="comment">// you can expose PyCell to Python snippets</span>
|
||
<span class="ident">pyo3</span>::<span class="macro">py_run</span><span class="macro">!</span>(<span class="ident">py</span>, <span class="ident">book_cell</span>, <span class="string">"assert book_cell.name[-6:] == 'Castle'"</span>);</pre></div>
|
||
<p>You can use <code>slf: &PyCell<Self></code> as an alternative <code>self</code> receiver of <code>#[pymethod]</code>,
|
||
though you rarely need it.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">HashMap</span>;
|
||
<span class="attribute">#[<span class="ident">pyclass</span>]</span>
|
||
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Default</span>)]</span>
|
||
<span class="kw">struct</span> <span class="ident">Counter</span> {
|
||
<span class="ident">counter</span>: <span class="ident">HashMap</span><span class="op"><</span><span class="ident">String</span>, <span class="ident">usize</span><span class="op">></span>
|
||
}
|
||
<span class="attribute">#[<span class="ident">pymethods</span>]</span>
|
||
<span class="kw">impl</span> <span class="ident">Counter</span> {
|
||
<span class="comment">// You can use &mut self here, but now we use &PyCell for demonstration</span>
|
||
<span class="kw">fn</span> <span class="ident">increment</span>(<span class="ident">slf</span>: <span class="kw-2">&</span><span class="ident">PyCell</span><span class="op"><</span><span class="self">Self</span><span class="op">></span>, <span class="ident">name</span>: <span class="ident">String</span>) <span class="op">-</span><span class="op">></span> <span class="ident">PyResult</span><span class="op"><</span><span class="ident">usize</span><span class="op">></span> {
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">slf_mut</span> <span class="op">=</span> <span class="ident">slf</span>.<span class="ident">try_borrow_mut</span>()<span class="question-mark">?</span>;
|
||
<span class="comment">// Now a mutable reference exists so we cannot get another one</span>
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">slf</span>.<span class="ident">try_borrow</span>().<span class="ident">is_err</span>());
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">slf</span>.<span class="ident">try_borrow_mut</span>().<span class="ident">is_err</span>());
|
||
<span class="kw">let</span> <span class="ident">counter</span> <span class="op">=</span> <span class="ident">slf_mut</span>.<span class="ident">counter</span>.<span class="ident">entry</span>(<span class="ident">name</span>).<span class="ident">or_insert</span>(<span class="number">0</span>);
|
||
<span class="kw-2">*</span><span class="ident">counter</span> <span class="op">+</span><span class="op">=</span> <span class="number">1</span>;
|
||
<span class="prelude-val">Ok</span>(<span class="kw-2">*</span><span class="ident">counter</span>)
|
||
}
|
||
}</pre></div>
|
||
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl<T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#199-392" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.new" class="method"><code>pub fn <a href="#method.new" class="fnname">new</a>(<br> py: <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'_>, <br> value: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="struct" href="../../pyo3/pyclass_init/struct.PyClassInitializer.html" title="struct pyo3::pyclass_init::PyClassInitializer">PyClassInitializer</a><T>><br>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self> <span class="where fmt-newline">where<br> T::<a class="type" href="../../pyo3/type_object/trait.PyTypeInfo.html#associatedtype.BaseLayout" title="type pyo3::type_object::PyTypeInfo::BaseLayout">BaseLayout</a>: <a class="trait" href="../../pyo3/type_object/trait.PyBorrowFlagLayout.html" title="trait pyo3::type_object::PyBorrowFlagLayout">PyBorrowFlagLayout</a><T::<a class="type" href="../../pyo3/type_object/trait.PyTypeInfo.html#associatedtype.BaseType" title="type pyo3::type_object::PyTypeInfo::BaseType">BaseType</a>>, </span></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#205-214" title="goto source code">[src]</a></h4><div class="docblock"><p>Make a new <code>PyCell</code> on the Python heap and return the reference to it.</p>
|
||
<p>In cases where the value in the cell does not need to be accessed immediately after
|
||
creation, consider <a href="../instance/struct.Py.html#method.new"><code>Py::new</code></a> as a more efficient
|
||
alternative.</p>
|
||
</div><h4 id="method.borrow" class="method"><code>pub fn <a href="#method.borrow" class="fnname">borrow</a>(&self) -> <a class="struct" href="../../pyo3/pycell/struct.PyRef.html" title="struct pyo3::pycell::PyRef">PyRef</a><'_, T></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#222-224" title="goto source code">[src]</a></h4><div class="docblock"><p>Immutably borrows the value <code>T</code>. This borrow lasts untill the returned <code>PyRef</code> exists.</p>
|
||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||
<p>Panics if the value is currently mutably borrowed. For a non-panicking variant, use
|
||
<a href="#method.try_borrow"><code>try_borrow</code></a>.</p>
|
||
</div><h4 id="method.borrow_mut" class="method"><code>pub fn <a href="#method.borrow_mut" class="fnname">borrow_mut</a>(&self) -> <a class="struct" href="../../pyo3/pycell/struct.PyRefMut.html" title="struct pyo3::pycell::PyRefMut">PyRefMut</a><'_, T></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#232-234" title="goto source code">[src]</a></h4><div class="docblock"><p>Mutably borrows the value <code>T</code>. This borrow lasts untill the returned <code>PyRefMut</code> exists.</p>
|
||
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
|
||
<p>Panics if the value is currently mutably borrowed. For a non-panicking variant, use
|
||
<a href="#method.try_borrow_mut"><code>try_borrow_mut</code></a>.</p>
|
||
</div><h4 id="method.try_borrow" class="method"><code>pub fn <a href="#method.try_borrow" class="fnname">try_borrow</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../pyo3/pycell/struct.PyRef.html" title="struct pyo3::pycell::PyRef">PyRef</a><'_, T>, <a class="struct" href="../../pyo3/pycell/struct.PyBorrowError.html" title="struct pyo3::pycell::PyBorrowError">PyBorrowError</a>></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#260-269" title="goto source code">[src]</a></h4><div class="docblock"><p>Immutably borrows the value <code>T</code>, returning an error if the value is currently
|
||
mutably borrowed. This borrow lasts untill the returned <code>PyRef</code> exists.</p>
|
||
<p>This is the non-panicking variant of <a href="#method.borrow"><code>borrow</code></a>.</p>
|
||
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="attribute">#[<span class="ident">pyclass</span>]</span>
|
||
<span class="kw">struct</span> <span class="ident">Class</span> {}
|
||
<span class="kw">let</span> <span class="ident">gil</span> <span class="op">=</span> <span class="ident">Python</span>::<span class="ident">acquire_gil</span>();
|
||
<span class="kw">let</span> <span class="ident">py</span> <span class="op">=</span> <span class="ident">gil</span>.<span class="ident">python</span>();
|
||
<span class="kw">let</span> <span class="ident">c</span> <span class="op">=</span> <span class="ident">PyCell</span>::<span class="ident">new</span>(<span class="ident">py</span>, <span class="ident">Class</span> {}).<span class="ident">unwrap</span>();
|
||
{
|
||
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">c</span>.<span class="ident">borrow_mut</span>();
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">c</span>.<span class="ident">try_borrow</span>().<span class="ident">is_err</span>());
|
||
}
|
||
|
||
{
|
||
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">c</span>.<span class="ident">borrow</span>();
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">c</span>.<span class="ident">try_borrow</span>().<span class="ident">is_ok</span>());
|
||
}</pre></div>
|
||
</div><h4 id="method.try_borrow_mut" class="method"><code>pub fn <a href="#method.try_borrow_mut" class="fnname">try_borrow_mut</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="../../pyo3/pycell/struct.PyRefMut.html" title="struct pyo3::pycell::PyRefMut">PyRefMut</a><'_, T>, <a class="struct" href="../../pyo3/pycell/struct.PyBorrowMutError.html" title="struct pyo3::pycell::PyBorrowMutError">PyBorrowMutError</a>></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#292-300" title="goto source code">[src]</a></h4><div class="docblock"><p>Mutably borrows the value <code>T</code>, returning an error if the value is currently borrowed.
|
||
This borrow lasts untill the returned <code>PyRefMut</code> exists.</p>
|
||
<p>This is the non-panicking variant of <a href="#method.borrow_mut"><code>borrow_mut</code></a>.</p>
|
||
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="attribute">#[<span class="ident">pyclass</span>]</span>
|
||
<span class="kw">struct</span> <span class="ident">Class</span> {}
|
||
<span class="kw">let</span> <span class="ident">gil</span> <span class="op">=</span> <span class="ident">Python</span>::<span class="ident">acquire_gil</span>();
|
||
<span class="kw">let</span> <span class="ident">py</span> <span class="op">=</span> <span class="ident">gil</span>.<span class="ident">python</span>();
|
||
<span class="kw">let</span> <span class="ident">c</span> <span class="op">=</span> <span class="ident">PyCell</span>::<span class="ident">new</span>(<span class="ident">py</span>, <span class="ident">Class</span> {}).<span class="ident">unwrap</span>();
|
||
{
|
||
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">c</span>.<span class="ident">borrow</span>();
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">c</span>.<span class="ident">try_borrow_mut</span>().<span class="ident">is_err</span>());
|
||
}
|
||
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">c</span>.<span class="ident">try_borrow_mut</span>().<span class="ident">is_ok</span>());</pre></div>
|
||
</div><h4 id="method.try_borrow_unguarded" class="method"><code>pub unsafe fn <a href="#method.try_borrow_unguarded" class="fnname">try_borrow_unguarded</a>(&self) -> <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.reference.html">&</a>T, <a class="struct" href="../../pyo3/pycell/struct.PyBorrowError.html" title="struct pyo3::pycell::PyBorrowError">PyBorrowError</a>></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#331-338" title="goto source code">[src]</a></h4><div class="docblock"><p>Immutably borrows the value <code>T</code>, returning an error if the value is
|
||
currently mutably borrowed.</p>
|
||
<h1 id="safety" class="section-header"><a href="#safety">Safety</a></h1>
|
||
<p>This method is unsafe because it does not return a <code>PyRef</code>,
|
||
thus leaving the borrow flag untouched. Mutably borrowing the <code>PyCell</code>
|
||
while the reference returned by this method is alive is undefined behaviour.</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="attribute">#[<span class="ident">pyclass</span>]</span>
|
||
<span class="kw">struct</span> <span class="ident">Class</span> {}
|
||
<span class="kw">let</span> <span class="ident">gil</span> <span class="op">=</span> <span class="ident">Python</span>::<span class="ident">acquire_gil</span>();
|
||
<span class="kw">let</span> <span class="ident">py</span> <span class="op">=</span> <span class="ident">gil</span>.<span class="ident">python</span>();
|
||
<span class="kw">let</span> <span class="ident">c</span> <span class="op">=</span> <span class="ident">PyCell</span>::<span class="ident">new</span>(<span class="ident">py</span>, <span class="ident">Class</span> {}).<span class="ident">unwrap</span>();
|
||
|
||
{
|
||
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">c</span>.<span class="ident">borrow_mut</span>();
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="kw">unsafe</span> { <span class="ident">c</span>.<span class="ident">try_borrow_unguarded</span>() }.<span class="ident">is_err</span>());
|
||
}
|
||
|
||
{
|
||
<span class="kw">let</span> <span class="ident">m</span> <span class="op">=</span> <span class="ident">c</span>.<span class="ident">borrow</span>();
|
||
<span class="macro">assert</span><span class="macro">!</span>(<span class="kw">unsafe</span> { <span class="ident">c</span>.<span class="ident">try_borrow_unguarded</span>() }.<span class="ident">is_ok</span>());
|
||
}</pre></div>
|
||
</div><h4 id="method.replace" class="method"><code>pub fn <a href="#method.replace" class="fnname">replace</a>(&self, t: T) -> T</code><a class="srclink" href="../../src/pyo3/pycell.rs.html#346-348" title="goto source code">[src]</a></h4><div class="docblock"><p>Replaces the wrapped value with a new one, returning the old value,</p>
|
||
<h1 id="panics-2" class="section-header"><a href="#panics-2">Panics</a></h1>
|
||
<p>Panics if the value is currently borrowed.</p>
|
||
</div><h4 id="method.replace_with" class="method"><code>pub fn <a href="#method.replace_with" class="fnname">replace_with</a><F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T) -> T>(&self, f: F) -> T</code><a class="srclink" href="../../src/pyo3/pycell.rs.html#355-359" title="goto source code">[src]</a></h4><div class="docblock"><p>Replaces the wrapped value with a new one computed from <code>f</code>, returning the old value.</p>
|
||
<h1 id="panics-3" class="section-header"><a href="#panics-3">Panics</a></h1>
|
||
<p>Panics if the value is currently borrowed.</p>
|
||
</div><h4 id="method.swap" class="method"><code>pub fn <a href="#method.swap" class="fnname">swap</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self)</code><a class="srclink" href="../../src/pyo3/pycell.rs.html#367-369" title="goto source code">[src]</a></h4><div class="docblock"><p>Swaps the wrapped value of <code>self</code> with the wrapped value of <code>other</code>.</p>
|
||
<h1 id="panics-4" class="section-header"><a href="#panics-4">Panics</a></h1>
|
||
<p>Panics if the value in either <code>PyCell</code> is currently borrowed.</p>
|
||
</div></div><h2 id="deref-methods" class="small-section-header">Methods from <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a><Target = <a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>><a href="#deref-methods" class="anchor"></a></h2><div class="impl-items"><h4 id="method.downcast" class="method"><code>pub fn <a href="#method.downcast" class="fnname">downcast</a><T>(&self) -> <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.reference.html">&</a>T, <a class="struct" href="../../pyo3/struct.PyDowncastError.html" title="struct pyo3::PyDowncastError">PyDowncastError</a><'_>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../pyo3/conversion/trait.PyTryFrom.html" title="trait pyo3::conversion::PyTryFrom">PyTryFrom</a><'py>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#65-70" title="goto source code">[src]</a></h4><div class="docblock"><p>Convert this PyAny to a concrete Python type.</p>
|
||
</div><h4 id="method.hasattr" class="method"><code>pub fn <a href="#method.hasattr" class="fnname">hasattr</a><N>(&self, attr_name: N) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>> <span class="where fmt-newline">where<br> N: <a class="trait" href="../../pyo3/conversion/trait.ToPyObject.html" title="trait pyo3::conversion::ToPyObject">ToPyObject</a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#75-82" title="goto source code">[src]</a></h4><div class="docblock"><p>Determines whether this object has the given attribute.</p>
|
||
<p>This is equivalent to the Python expression <code>hasattr(self, attr_name)</code>.</p>
|
||
</div><h4 id="method.getattr" class="method"><code>pub fn <a href="#method.getattr" class="fnname">getattr</a><N>(&self, attr_name: N) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>> <span class="where fmt-newline">where<br> N: <a class="trait" href="../../pyo3/conversion/trait.ToPyObject.html" title="trait pyo3::conversion::ToPyObject">ToPyObject</a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#87-95" title="goto source code">[src]</a></h4><div class="docblock"><p>Retrieves an attribute value.</p>
|
||
<p>This is equivalent to the Python expression <code>self.attr_name</code>.</p>
|
||
</div><h4 id="method.setattr" class="method"><code>pub fn <a href="#method.setattr" class="fnname">setattr</a><N, V>(&self, attr_name: N, value: V) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> <span class="where fmt-newline">where<br> N: <a class="trait" href="../../pyo3/conversion/trait.ToBorrowedObject.html" title="trait pyo3::conversion::ToBorrowedObject">ToBorrowedObject</a>,<br> V: <a class="trait" href="../../pyo3/conversion/trait.ToBorrowedObject.html" title="trait pyo3::conversion::ToBorrowedObject">ToBorrowedObject</a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#100-113" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets an attribute value.</p>
|
||
<p>This is equivalent to the Python expression <code>self.attr_name = value</code>.</p>
|
||
</div><h4 id="method.delattr" class="method"><code>pub fn <a href="#method.delattr" class="fnname">delattr</a><N>(&self, attr_name: N) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> <span class="where fmt-newline">where<br> N: <a class="trait" href="../../pyo3/conversion/trait.ToPyObject.html" title="trait pyo3::conversion::ToPyObject">ToPyObject</a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#118-125" title="goto source code">[src]</a></h4><div class="docblock"><p>Deletes an attribute.</p>
|
||
<p>This is equivalent to the Python expression <code>del self.attr_name</code>.</p>
|
||
</div><h4 id="method.compare" class="method"><code>pub fn <a href="#method.compare" class="fnname">compare</a><O>(&self, other: O) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>> <span class="where fmt-newline">where<br> O: <a class="trait" href="../../pyo3/conversion/trait.ToPyObject.html" title="trait pyo3::conversion::ToPyObject">ToPyObject</a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#140-164" title="goto source code">[src]</a></h4><div class="docblock"><p>Compares two Python objects.</p>
|
||
<p>This is equivalent to:</p>
|
||
<pre><code class="language-python">if self == other:
|
||
return Equal
|
||
elif a < b:
|
||
return Less
|
||
elif a > b:
|
||
return Greater
|
||
else:
|
||
raise TypeError("PyAny::compare(): All comparisons returned false")
|
||
</code></pre>
|
||
</div><h4 id="method.rich_compare" class="method"><code>pub fn <a href="#method.rich_compare" class="fnname">rich_compare</a><O>(<br> &self, <br> other: O, <br> compare_op: <a class="enum" href="../../pyo3/class/basic/enum.CompareOp.html" title="enum pyo3::class::basic::CompareOp">CompareOp</a><br>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>> <span class="where fmt-newline">where<br> O: <a class="trait" href="../../pyo3/conversion/trait.ToPyObject.html" title="trait pyo3::conversion::ToPyObject">ToPyObject</a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#176-189" title="goto source code">[src]</a></h4><div class="docblock"><p>Compares two Python objects.</p>
|
||
<p>Depending on the value of <code>compare_op</code>, this is equivalent to one of the
|
||
following Python expressions:</p>
|
||
<ul>
|
||
<li>CompareOp::Eq: <code>self == other</code></li>
|
||
<li>CompareOp::Ne: <code>self != other</code></li>
|
||
<li>CompareOp::Lt: <code>self < other</code></li>
|
||
<li>CompareOp::Le: <code>self <= other</code></li>
|
||
<li>CompareOp::Gt: <code>self > other</code></li>
|
||
<li>CompareOp::Ge: <code>self >= other</code></li>
|
||
</ul>
|
||
</div><h4 id="method.is_callable" class="method"><code>pub fn <a href="#method.is_callable" class="fnname">is_callable</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#192-194" title="goto source code">[src]</a></h4><div class="docblock"><p>Determines whether this object is callable.</p>
|
||
</div><h4 id="method.call" class="method"><code>pub fn <a href="#method.call" class="fnname">call</a>(<br> &self, <br> args: impl <a class="trait" href="../../pyo3/conversion/trait.IntoPy.html" title="trait pyo3::conversion::IntoPy">IntoPy</a><<a class="struct" href="../../pyo3/prelude/struct.Py.html" title="struct pyo3::prelude::Py">Py</a><<a class="struct" href="../../pyo3/types/struct.PyTuple.html" title="struct pyo3::types::PyTuple">PyTuple</a>>>, <br> kwargs: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="../../pyo3/types/struct.PyDict.html" title="struct pyo3::types::PyDict">PyDict</a>><br>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#199-215" title="goto source code">[src]</a></h4><div class="docblock"><p>Calls the object.</p>
|
||
<p>This is equivalent to the Python expression <code>self(*args, **kwargs)</code>.</p>
|
||
</div><h4 id="method.call0" class="method"><code>pub fn <a href="#method.call0" class="fnname">call0</a>(&self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#220-233" title="goto source code">[src]</a></h4><div class="docblock"><p>Calls the object without arguments.</p>
|
||
<p>This is equivalent to the Python expression <code>self()</code>.</p>
|
||
</div><h4 id="method.call1" class="method"><code>pub fn <a href="#method.call1" class="fnname">call1</a>(&self, args: impl <a class="trait" href="../../pyo3/conversion/trait.IntoPy.html" title="trait pyo3::conversion::IntoPy">IntoPy</a><<a class="struct" href="../../pyo3/prelude/struct.Py.html" title="struct pyo3::prelude::Py">Py</a><<a class="struct" href="../../pyo3/types/struct.PyTuple.html" title="struct pyo3::types::PyTuple">PyTuple</a>>>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#238-240" title="goto source code">[src]</a></h4><div class="docblock"><p>Calls the object with only positional arguments.</p>
|
||
<p>This is equivalent to the Python expression <code>self(*args)</code>.</p>
|
||
</div><h4 id="method.call_method" class="method"><code>pub fn <a href="#method.call_method" class="fnname">call_method</a>(<br> &self, <br> name: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br> args: impl <a class="trait" href="../../pyo3/conversion/trait.IntoPy.html" title="trait pyo3::conversion::IntoPy">IntoPy</a><<a class="struct" href="../../pyo3/prelude/struct.Py.html" title="struct pyo3::prelude::Py">Py</a><<a class="struct" href="../../pyo3/types/struct.PyTuple.html" title="struct pyo3::types::PyTuple">PyTuple</a>>>, <br> kwargs: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="../../pyo3/types/struct.PyDict.html" title="struct pyo3::types::PyDict">PyDict</a>><br>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#262-283" title="goto source code">[src]</a></h4><div class="docblock"><p>Calls a method on the object.</p>
|
||
<p>This is equivalent to the Python expression <code>self.name(*args, **kwargs)</code>.</p>
|
||
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">pyo3</span>::<span class="ident">types</span>::<span class="ident">IntoPyDict</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">gil</span> <span class="op">=</span> <span class="ident">Python</span>::<span class="ident">acquire_gil</span>();
|
||
<span class="kw">let</span> <span class="ident">py</span> <span class="op">=</span> <span class="ident">gil</span>.<span class="ident">python</span>();
|
||
<span class="kw">let</span> <span class="ident">list</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">3</span>, <span class="number">6</span>, <span class="number">5</span>, <span class="number">4</span>, <span class="number">7</span>].<span class="ident">to_object</span>(<span class="ident">py</span>);
|
||
<span class="kw">let</span> <span class="ident">dict</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[(<span class="string">"reverse"</span>, <span class="bool-val">true</span>)].<span class="ident">into_py_dict</span>(<span class="ident">py</span>);
|
||
<span class="ident">list</span>.<span class="ident">call_method</span>(<span class="ident">py</span>, <span class="string">"sort"</span>, (), <span class="prelude-val">Some</span>(<span class="ident">dict</span>)).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">list</span>.<span class="ident">extract</span>::<span class="op"><</span><span class="ident">Vec</span><span class="op"><</span><span class="ident">i32</span><span class="op">></span><span class="op">></span>(<span class="ident">py</span>).<span class="ident">unwrap</span>(), <span class="macro">vec</span><span class="macro">!</span>[<span class="number">7</span>, <span class="number">6</span>, <span class="number">5</span>, <span class="number">4</span>, <span class="number">3</span>]);
|
||
|
||
<span class="kw">let</span> <span class="ident">new_element</span> <span class="op">=</span> <span class="number">1</span>.<span class="ident">to_object</span>(<span class="ident">py</span>);
|
||
<span class="ident">list</span>.<span class="ident">call_method</span>(<span class="ident">py</span>, <span class="string">"append"</span>, (<span class="ident">new_element</span>,), <span class="prelude-val">None</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">list</span>.<span class="ident">extract</span>::<span class="op"><</span><span class="ident">Vec</span><span class="op"><</span><span class="ident">i32</span><span class="op">></span><span class="op">></span>(<span class="ident">py</span>).<span class="ident">unwrap</span>(), <span class="macro">vec</span><span class="macro">!</span>[<span class="number">7</span>, <span class="number">6</span>, <span class="number">5</span>, <span class="number">4</span>, <span class="number">3</span>, <span class="number">1</span>]);</pre></div>
|
||
</div><h4 id="method.call_method0" class="method"><code>pub fn <a href="#method.call_method0" class="fnname">call_method0</a>(&self, name: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#288-300" title="goto source code">[src]</a></h4><div class="docblock"><p>Calls a method on the object without arguments.</p>
|
||
<p>This is equivalent to the Python expression <code>self.name()</code>.</p>
|
||
</div><h4 id="method.call_method1" class="method"><code>pub fn <a href="#method.call_method1" class="fnname">call_method1</a>(<br> &self, <br> name: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br> args: impl <a class="trait" href="../../pyo3/conversion/trait.IntoPy.html" title="trait pyo3::conversion::IntoPy">IntoPy</a><<a class="struct" href="../../pyo3/prelude/struct.Py.html" title="struct pyo3::prelude::Py">Py</a><<a class="struct" href="../../pyo3/types/struct.PyTuple.html" title="struct pyo3::types::PyTuple">PyTuple</a>>><br>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#305-307" title="goto source code">[src]</a></h4><div class="docblock"><p>Calls a method on the object with only positional arguments.</p>
|
||
<p>This is equivalent to the Python expression <code>self.name(*args)</code>.</p>
|
||
</div><h4 id="method.is_true" class="method"><code>pub fn <a href="#method.is_true" class="fnname">is_true</a>(&self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#312-319" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns whether the object is considered to be true.</p>
|
||
<p>This is equivalent to the Python expression <code>bool(self)</code>.</p>
|
||
</div><h4 id="method.is_none" class="method"><code>pub fn <a href="#method.is_none" class="fnname">is_none</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#324-326" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns whether the object is considered to be None.</p>
|
||
<p>This is equivalent to the Python expression <code>self is None</code>.</p>
|
||
</div><h4 id="method.is_empty" class="method"><code>pub fn <a href="#method.is_empty" class="fnname">is_empty</a>(&self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#331-333" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns true if the sequence or mapping has a length of 0.</p>
|
||
<p>This is equivalent to the Python expression <code>len(self) == 0</code>.</p>
|
||
</div><h4 id="method.get_item" class="method"><code>pub fn <a href="#method.get_item" class="fnname">get_item</a><K>(&self, key: K) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>> <span class="where fmt-newline">where<br> K: <a class="trait" href="../../pyo3/conversion/trait.ToBorrowedObject.html" title="trait pyo3::conversion::ToBorrowedObject">ToBorrowedObject</a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#338-346" title="goto source code">[src]</a></h4><div class="docblock"><p>Gets an item from the collection.</p>
|
||
<p>This is equivalent to the Python expression <code>self[key]</code>.</p>
|
||
</div><h4 id="method.set_item" class="method"><code>pub fn <a href="#method.set_item" class="fnname">set_item</a><K, V>(&self, key: K, value: V) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> <span class="where fmt-newline">where<br> K: <a class="trait" href="../../pyo3/conversion/trait.ToBorrowedObject.html" title="trait pyo3::conversion::ToBorrowedObject">ToBorrowedObject</a>,<br> V: <a class="trait" href="../../pyo3/conversion/trait.ToBorrowedObject.html" title="trait pyo3::conversion::ToBorrowedObject">ToBorrowedObject</a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#351-361" title="goto source code">[src]</a></h4><div class="docblock"><p>Sets a collection item value.</p>
|
||
<p>This is equivalent to the Python expression <code>self[key] = value</code>.</p>
|
||
</div><h4 id="method.del_item" class="method"><code>pub fn <a href="#method.del_item" class="fnname">del_item</a><K>(&self, key: K) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> <span class="where fmt-newline">where<br> K: <a class="trait" href="../../pyo3/conversion/trait.ToBorrowedObject.html" title="trait pyo3::conversion::ToBorrowedObject">ToBorrowedObject</a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#366-373" title="goto source code">[src]</a></h4><div class="docblock"><p>Deletes an item from the collection.</p>
|
||
<p>This is equivalent to the Python expression <code>del self[key]</code>.</p>
|
||
</div><h4 id="method.iter" class="method"><code>pub fn <a href="#method.iter" class="fnname">iter</a>(&self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/types/struct.PyIterator.html" title="struct pyo3::types::PyIterator">PyIterator</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#379-381" title="goto source code">[src]</a></h4><div class="docblock"><p>Takes an object and returns an iterator for it.</p>
|
||
<p>This is typically a new iterator but if the argument is an iterator,
|
||
this returns itself.</p>
|
||
</div><h4 id="method.get_type" class="method"><code>pub fn <a href="#method.get_type" class="fnname">get_type</a>(&self) -> &<a class="struct" href="../../pyo3/types/struct.PyType.html" title="struct pyo3::types::PyType">PyType</a></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#384-386" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the Python type object for this object’s type.</p>
|
||
</div><h4 id="method.get_type_ptr" class="method"><code>pub fn <a href="#method.get_type_ptr" class="fnname">get_type_ptr</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyTypeObject.html" title="struct pyo3::ffi::PyTypeObject">PyTypeObject</a></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#390-392" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the Python type pointer for this object.</p>
|
||
</div><h4 id="method.cast_as" class="method"><code>pub fn <a href="#method.cast_as" class="fnname">cast_as</a><'a, D>(&'a self) -> <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.reference.html">&'a </a>D, <a class="struct" href="../../pyo3/struct.PyDowncastError.html" title="struct pyo3::PyDowncastError">PyDowncastError</a><'_>> <span class="where fmt-newline">where<br> D: <a class="trait" href="../../pyo3/conversion/trait.PyTryFrom.html" title="trait pyo3::conversion::PyTryFrom">PyTryFrom</a><'a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#397-402" title="goto source code">[src]</a></h4><div class="docblock"><p>Casts the PyObject to a concrete Python object type.</p>
|
||
<p>This can cast only to native Python types, not types implemented in Rust.</p>
|
||
</div><h4 id="method.extract" class="method"><code>pub fn <a href="#method.extract" class="fnname">extract</a><'a, D>(&'a self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><D> <span class="where fmt-newline">where<br> D: <a class="trait" href="../../pyo3/conversion/trait.FromPyObject.html" title="trait pyo3::conversion::FromPyObject">FromPyObject</a><'a>, </span></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#407-412" title="goto source code">[src]</a></h4><div class="docblock"><p>Extracts some type from the Python object.</p>
|
||
<p>This is a wrapper function around <code>FromPyObject::extract()</code>.</p>
|
||
</div><h4 id="method.get_refcnt" class="method"><code>pub fn <a href="#method.get_refcnt" class="fnname">get_refcnt</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#415-417" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the reference count for the Python object.</p>
|
||
</div><h4 id="method.repr" class="method"><code>pub fn <a href="#method.repr" class="fnname">repr</a>(&self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/types/struct.PyString.html" title="struct pyo3::types::PyString">PyString</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#422-427" title="goto source code">[src]</a></h4><div class="docblock"><p>Computes the “repr” representation of self.</p>
|
||
<p>This is equivalent to the Python expression <code>repr(self)</code>.</p>
|
||
</div><h4 id="method.str" class="method"><code>pub fn <a href="#method.str" class="fnname">str</a>(&self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><&<a class="struct" href="../../pyo3/types/struct.PyString.html" title="struct pyo3::types::PyString">PyString</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#432-437" title="goto source code">[src]</a></h4><div class="docblock"><p>Computes the “str” representation of self.</p>
|
||
<p>This is equivalent to the Python expression <code>str(self)</code>.</p>
|
||
</div><h4 id="method.hash" class="method"><code>pub fn <a href="#method.hash" class="fnname">hash</a>(&self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.isize.html">isize</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#442-449" title="goto source code">[src]</a></h4><div class="docblock"><p>Retrieves the hash code of self.</p>
|
||
<p>This is equivalent to the Python expression <code>hash(self)</code>.</p>
|
||
</div><h4 id="method.len" class="method"><code>pub fn <a href="#method.len" class="fnname">len</a>(&self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#454-461" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the length of the sequence or mapping.</p>
|
||
<p>This is equivalent to the Python expression <code>len(self)</code>.</p>
|
||
</div><h4 id="method.dir" class="method"><code>pub fn <a href="#method.dir" class="fnname">dir</a>(&self) -> &<a class="struct" href="../../pyo3/types/struct.PyList.html" title="struct pyo3::types::PyList">PyList</a></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#466-468" title="goto source code">[src]</a></h4><div class="docblock"><p>Returns the list of attributes of this object.</p>
|
||
<p>This is equivalent to the Python expression <code>dir(self)</code>.</p>
|
||
</div><h4 id="method.is_instance" class="method"><code>pub fn <a href="#method.is_instance" class="fnname">is_instance</a><T: <a class="trait" href="../../pyo3/type_object/trait.PyTypeObject.html" title="trait pyo3::type_object::PyTypeObject">PyTypeObject</a>>(&self) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>></code><a class="srclink" href="../../src/pyo3/types/any.rs.html#473-475" title="goto source code">[src]</a></h4><div class="docblock"><p>Checks whether this object is an instance of type <code>T</code>.</p>
|
||
<p>This is equivalent to the Python expression <code>isinstance(self, T)</code>.</p>
|
||
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsPyPointer" class="impl"><code class="in-band">impl<T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> <a class="trait" href="../../pyo3/conversion/trait.AsPyPointer.html" title="trait pyo3::conversion::AsPyPointer">AsPyPointer</a> for <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl-AsPyPointer" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#410-414" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ptr" class="method hidden"><code>fn <a href="../../pyo3/conversion/trait.AsPyPointer.html#tymethod.as_ptr" class="fnname">as_ptr</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyObject.html" title="struct pyo3::ffi::PyObject">PyObject</a></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#411-413" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Retrieves the underlying FFI pointer (as a borrowed pointer).</p>
|
||
</div></div><h3 id="impl-AsRef%3CPyAny%3E" class="impl"><code class="in-band">impl<T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>> for <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl-AsRef%3CPyAny%3E" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#422-426" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&self) -> &<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#423-425" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl<T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>> <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="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#436-453" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>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="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#437-452" 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-Deref" class="impl"><code class="in-band">impl<T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl-Deref" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#428-434" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Target" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target" class="type">Target</a> = <a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a></code></h4><div class='docblock'><p>The resulting type after dereferencing.</p>
|
||
</div><h4 id="method.deref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#tymethod.deref" class="fnname">deref</a>(&self) -> &<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#431-433" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Dereferences the value.</p>
|
||
</div></div><h3 id="impl-From%3C%26%27_%20PyCell%3CT%3E%3E" class="impl"><code class="in-band">impl<'a, T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><&'_ <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T>> for <a class="struct" href="../../pyo3/prelude/struct.Py.html" title="struct pyo3::prelude::Py">Py</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>, </span></code><a href="#impl-From%3C%26%27_%20PyCell%3CT%3E%3E" class="anchor"></a><a class="srclink" href="../../src/pyo3/instance.rs.html#513-520" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(cell: &<a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T>) -> Self</code><a class="srclink" href="../../src/pyo3/instance.rs.html#517-519" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id="impl-FromPyObject%3C%27a%3E" class="impl"><code class="in-band">impl<'a, T> <a class="trait" href="../../pyo3/conversion/trait.FromPyObject.html" title="trait pyo3::conversion::FromPyObject">FromPyObject</a><'a> for &'a <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>, </span></code><a href="#impl-FromPyObject%3C%27a%3E" class="anchor"></a><a class="srclink" href="../../src/pyo3/conversion.rs.html#228-235" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.extract-1" class="method hidden"><code>fn <a href="../../pyo3/conversion/trait.FromPyObject.html#tymethod.extract" class="fnname">extract</a>(obj: &'a <a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><Self></code><a class="srclink" href="../../src/pyo3/conversion.rs.html#232-234" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Extracts <code>Self</code> from the source <code>PyObject</code>.</p>
|
||
</div></div><h3 id="impl-PyLayout%3CT%3E" class="impl"><code class="in-band">impl<T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> <a class="trait" href="../../pyo3/type_object/trait.PyLayout.html" title="trait pyo3::type_object::PyLayout">PyLayout</a><T> for <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl-PyLayout%3CT%3E" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#394-408" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedconstant.IS_NATIVE_TYPE" class="associatedconstant hidden"><code>const <a href="../../pyo3/type_object/trait.PyLayout.html#associatedconstant.IS_NATIVE_TYPE" class="constant"><b>IS_NATIVE_TYPE</b></a>: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#395" title="goto source code">[src]</a></h4><h4 id="method.get_super" class="method hidden"><code>fn <a href="../../pyo3/type_object/trait.PyLayout.html#method.get_super" class="fnname">get_super</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut T::<a class="type" href="../../pyo3/type_object/trait.PyTypeInfo.html#associatedtype.BaseLayout" title="type pyo3::type_object::PyTypeInfo::BaseLayout">BaseLayout</a>></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#396-398" title="goto source code">[src]</a></h4><h4 id="method.py_init" class="method hidden"><code>fn <a href="../../pyo3/type_object/trait.PyLayout.html#method.py_init" class="fnname">py_init</a>(&mut self, value: T)</code><a class="srclink" href="../../src/pyo3/pycell.rs.html#399-401" title="goto source code">[src]</a></h4><h4 id="method.py_drop" class="method hidden"><code>unsafe fn <a href="../../pyo3/type_object/trait.PyLayout.html#method.py_drop" class="fnname">py_drop</a>(&mut self, py: <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'_>)</code><a class="srclink" href="../../src/pyo3/pycell.rs.html#402-407" title="goto source code">[src]</a></h4></div><h3 id="impl-PyNativeType" class="impl"><code class="in-band">impl<T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> <a class="trait" href="../../pyo3/trait.PyNativeType.html" title="trait pyo3::PyNativeType">PyNativeType</a> for <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl-PyNativeType" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#197" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.py" class="method hidden"><code>fn <a href="../../pyo3/trait.PyNativeType.html#method.py" class="fnname">py</a>(&self) -> <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'_></code><a class="srclink" href="../../src/pyo3/instance.rs.html#22-24" title="goto source code">[src]</a></h4><h4 id="method.unchecked_downcast" class="method hidden"><code>unsafe fn <a href="../../pyo3/trait.PyNativeType.html#method.unchecked_downcast" class="fnname">unchecked_downcast</a>(obj: &<a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>Self</code><a class="srclink" href="../../src/pyo3/instance.rs.html#31-33" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Cast <code>&PyAny</code> to <code>&Self</code> without no type checking. <a href="../../pyo3/trait.PyNativeType.html#method.unchecked_downcast">Read more</a></p>
|
||
</div></div><h3 id="impl-PyTryFrom%3C%27v%3E" class="impl"><code class="in-band">impl<'v, T> <a class="trait" href="../../pyo3/conversion/trait.PyTryFrom.html" title="trait pyo3::conversion::PyTryFrom">PyTryFrom</a><'v> for <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T> <span class="where fmt-newline">where<br> T: 'v + <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>, </span></code><a href="#impl-PyTryFrom%3C%27v%3E" class="anchor"></a><a class="srclink" href="../../src/pyo3/conversion.rs.html#355-383" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.try_from" class="method hidden"><code>fn <a href="../../pyo3/conversion/trait.PyTryFrom.html#tymethod.try_from" class="fnname">try_from</a><V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'v <a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>>>(<br> value: V<br>) -> <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.reference.html">&'v </a>Self, <a class="struct" href="../../pyo3/struct.PyDowncastError.html" title="struct pyo3::PyDowncastError">PyDowncastError</a><'v>></code><a class="srclink" href="../../src/pyo3/conversion.rs.html#359-368" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Cast from a concrete Python object type to PyObject.</p>
|
||
</div><h4 id="method.try_from_exact" class="method hidden"><code>fn <a href="../../pyo3/conversion/trait.PyTryFrom.html#tymethod.try_from_exact" class="fnname">try_from_exact</a><V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'v <a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>>>(<br> value: V<br>) -> <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.reference.html">&'v </a>Self, <a class="struct" href="../../pyo3/struct.PyDowncastError.html" title="struct pyo3::PyDowncastError">PyDowncastError</a><'v>></code><a class="srclink" href="../../src/pyo3/conversion.rs.html#369-378" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Cast from a concrete Python object type to PyObject. With exact type check.</p>
|
||
</div><h4 id="method.try_from_unchecked" class="method hidden"><code>unsafe fn <a href="../../pyo3/conversion/trait.PyTryFrom.html#tymethod.try_from_unchecked" class="fnname">try_from_unchecked</a><V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><&'v <a class="struct" href="../../pyo3/prelude/struct.PyAny.html" title="struct pyo3::prelude::PyAny">PyAny</a>>>(value: V) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'v </a>Self</code><a class="srclink" href="../../src/pyo3/conversion.rs.html#380-382" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Cast a PyAny to a specific type of PyObject. The caller must
|
||
have already verified the reference is for this type. <a href="../../pyo3/conversion/trait.PyTryFrom.html#tymethod.try_from_unchecked">Read more</a></p>
|
||
</div></div><h3 id="impl-ToPyObject" class="impl"><code class="in-band">impl<T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> <a class="trait" href="../../pyo3/conversion/trait.ToPyObject.html" title="trait pyo3::conversion::ToPyObject">ToPyObject</a> for &<a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl-ToPyObject" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#416-420" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.to_object" class="method hidden"><code>fn <a href="../../pyo3/conversion/trait.ToPyObject.html#tymethod.to_object" class="fnname">to_object</a>(&self, py: <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'_>) -> <a class="type" href="../../pyo3/prelude/type.PyObject.html" title="type pyo3::prelude::PyObject">PyObject</a></code><a class="srclink" href="../../src/pyo3/pycell.rs.html#417-419" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Converts self into a Python object.</p>
|
||
</div></div><h3 id="impl-TryFrom%3C%26%27a%20PyCell%3CT%3E%3E" class="impl"><code class="in-band">impl<'a, T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><&'a <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T>> for <a class="struct" href="../../pyo3/pycell/struct.PyRef.html" title="struct pyo3::pycell::PyRef">PyRef</a><'a, T></code><a href="#impl-TryFrom%3C%26%27a%20PyCell%3CT%3E%3E" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#587-592" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="struct" href="../../pyo3/pycell/struct.PyBorrowError.html" title="struct pyo3::pycell::PyBorrowError">PyBorrowError</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||
</div><h4 id="method.try_from-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(cell: &'a <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, Self::<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="../../src/pyo3/pycell.rs.html#589-591" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id="impl-TryFrom%3C%26%27a%20PyCell%3CT%3E%3E-1" class="impl"><code class="in-band">impl<'a, T: <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><&'a <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T>> for <a class="struct" href="../../pyo3/pycell/struct.PyRefMut.html" title="struct pyo3::pycell::PyRefMut">PyRefMut</a><'a, T></code><a href="#impl-TryFrom%3C%26%27a%20PyCell%3CT%3E%3E-1" class="anchor"></a><a class="srclink" href="../../src/pyo3/pycell.rs.html#691-696" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="struct" href="../../pyo3/pycell/struct.PyBorrowMutError.html" title="struct pyo3::pycell::PyBorrowMutError">PyBorrowMutError</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
|
||
</div><h4 id="method.try_from-2" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(cell: &'a <a class="struct" href="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, Self::<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="../../src/pyo3/pycell.rs.html#693-695" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></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-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="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl-RefUnwindSafe" class="anchor"></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="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</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>,<br> <T as <a class="trait" href="../../pyo3/type_object/trait.PyTypeInfo.html" title="trait pyo3::type_object::PyTypeInfo">PyTypeInfo</a>>::<a class="type" href="../../pyo3/type_object/trait.PyTypeInfo.html#associatedtype.BaseLayout" title="type pyo3::type_object::PyTypeInfo::BaseLayout">BaseLayout</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> <T as <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>>::<a class="type" href="../../pyo3/pyclass/trait.PyClass.html#associatedtype.Dict" title="type pyo3::pyclass::PyClass::Dict">Dict</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> <T as <a class="trait" href="../../pyo3/pyclass/trait.PyClassSend.html" title="trait pyo3::pyclass::PyClassSend">PyClassSend</a>>::<a class="type" href="../../pyo3/pyclass/trait.PyClassSend.html#associatedtype.ThreadChecker" title="type pyo3::pyclass::PyClassSend::ThreadChecker">ThreadChecker</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> <T as <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>>::<a class="type" href="../../pyo3/pyclass/trait.PyClass.html#associatedtype.WeakRef" title="type pyo3::pyclass::PyClass::WeakRef">WeakRef</a>: <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></h3><div class="impl-items"></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="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</a><T></code><a href="#impl-Sync" class="anchor"></a></h3><div class="impl-items"></div><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="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</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>,<br> <T as <a class="trait" href="../../pyo3/type_object/trait.PyTypeInfo.html" title="trait pyo3::type_object::PyTypeInfo">PyTypeInfo</a>>::<a class="type" href="../../pyo3/type_object/trait.PyTypeInfo.html#associatedtype.BaseLayout" title="type pyo3::type_object::PyTypeInfo::BaseLayout">BaseLayout</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,<br> <T as <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>>::<a class="type" href="../../pyo3/pyclass/trait.PyClass.html#associatedtype.Dict" title="type pyo3::pyclass::PyClass::Dict">Dict</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,<br> <T as <a class="trait" href="../../pyo3/pyclass/trait.PyClassSend.html" title="trait pyo3::pyclass::PyClassSend">PyClassSend</a>>::<a class="type" href="../../pyo3/pyclass/trait.PyClassSend.html#associatedtype.ThreadChecker" title="type pyo3::pyclass::PyClassSend::ThreadChecker">ThreadChecker</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,<br> <T as <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>>::<a class="type" href="../../pyo3/pyclass/trait.PyClass.html#associatedtype.WeakRef" title="type pyo3::pyclass::PyClass::WeakRef">WeakRef</a>: <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="../../pyo3/pycell/struct.PyCell.html" title="struct pyo3::pycell::PyCell">PyCell</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>,<br> <T as <a class="trait" href="../../pyo3/type_object/trait.PyTypeInfo.html" title="trait pyo3::type_object::PyTypeInfo">PyTypeInfo</a>>::<a class="type" href="../../pyo3/type_object/trait.PyTypeInfo.html#associatedtype.BaseLayout" title="type pyo3::type_object::PyTypeInfo::BaseLayout">BaseLayout</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a>,<br> <T as <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>>::<a class="type" href="../../pyo3/pyclass/trait.PyClass.html#associatedtype.Dict" title="type pyo3::pyclass::PyClass::Dict">Dict</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a>,<br> <T as <a class="trait" href="../../pyo3/pyclass/trait.PyClassSend.html" title="trait pyo3::pyclass::PyClassSend">PyClassSend</a>>::<a class="type" href="../../pyo3/pyclass/trait.PyClassSend.html#associatedtype.ThreadChecker" title="type pyo3::pyclass::PyClassSend::ThreadChecker">ThreadChecker</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a>,<br> <T as <a class="trait" href="../../pyo3/pyclass/trait.PyClass.html" title="trait pyo3::pyclass::PyClass">PyClass</a>>::<a class="type" href="../../pyo3/pyclass/trait.PyClass.html#associatedtype.WeakRef" title="type pyo3::pyclass::PyClass::WeakRef">WeakRef</a>: <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></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-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#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub 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#132" 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><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#208-213" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></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#216-220" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
|
||
</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/mod.rs.html#544-548" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from-1" class="method hidden"><code>pub 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/mod.rs.html#545" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div><h3 id="impl-FromPyPointer%3C%27p%3E" class="impl"><code class="in-band">impl<'p, T> <a class="trait" href="../../pyo3/conversion/trait.FromPyPointer.html" title="trait pyo3::conversion::FromPyPointer">FromPyPointer</a><'p> for T <span class="where fmt-newline">where<br> T: 'p + <a class="trait" href="../../pyo3/trait.PyNativeType.html" title="trait pyo3::PyNativeType">PyNativeType</a>, </span></code><a href="#impl-FromPyPointer%3C%27p%3E" class="anchor"></a><a class="srclink" href="../../src/pyo3/conversion.rs.html#462-476" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from_owned_ptr_or_opt" class="method hidden"><code>pub unsafe fn <a href="../../pyo3/conversion/trait.FromPyPointer.html#tymethod.from_owned_ptr_or_opt" class="fnname">from_owned_ptr_or_opt</a>(<a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'p>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyObject.html" title="struct pyo3::ffi::PyObject">PyObject</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'p </a>T></code><a class="srclink" href="../../src/pyo3/conversion.rs.html#466-469" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Convert from an arbitrary <code>PyObject</code>. <a href="../../pyo3/conversion/trait.FromPyPointer.html#tymethod.from_owned_ptr_or_opt">Read more</a></p>
|
||
</div><h4 id="method.from_borrowed_ptr_or_opt" class="method hidden"><code>pub unsafe fn <a href="../../pyo3/conversion/trait.FromPyPointer.html#tymethod.from_borrowed_ptr_or_opt" class="fnname">from_borrowed_ptr_or_opt</a>(<br> <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'p>, <br> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyObject.html" title="struct pyo3::ffi::PyObject">PyObject</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'p </a>T></code><a class="srclink" href="../../src/pyo3/conversion.rs.html#470-475" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Convert from an arbitrary borrowed <code>PyObject</code>. <a href="../../pyo3/conversion/trait.FromPyPointer.html#tymethod.from_borrowed_ptr_or_opt">Read more</a></p>
|
||
</div><h4 id="method.from_owned_ptr_or_panic" class="method hidden"><code>unsafe fn <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_owned_ptr_or_panic" class="fnname">from_owned_ptr_or_panic</a>(<br> py: <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'p>, <br> ptr: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyObject.html" title="struct pyo3::ffi::PyObject">PyObject</a><br>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'p </a>Self</code><a class="srclink" href="../../src/pyo3/conversion.rs.html#407-409" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Convert from an arbitrary <code>PyObject</code> or panic. <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_owned_ptr_or_panic">Read more</a></p>
|
||
</div><h4 id="method.from_owned_ptr" class="method hidden"><code>unsafe fn <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_owned_ptr" class="fnname">from_owned_ptr</a>(py: <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'p>, ptr: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyObject.html" title="struct pyo3::ffi::PyObject">PyObject</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'p </a>Self</code><a class="srclink" href="../../src/pyo3/conversion.rs.html#415-417" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Convert from an arbitrary <code>PyObject</code> or panic. <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_owned_ptr">Read more</a></p>
|
||
</div><h4 id="method.from_owned_ptr_or_err" class="method hidden"><code>unsafe fn <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_owned_ptr_or_err" class="fnname">from_owned_ptr_or_err</a>(<br> py: <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'p>, <br> ptr: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyObject.html" title="struct pyo3::ffi::PyObject">PyObject</a><br>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'p </a>Self></code><a class="srclink" href="../../src/pyo3/conversion.rs.html#423-425" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Convert from an arbitrary <code>PyObject</code>. <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_owned_ptr_or_err">Read more</a></p>
|
||
</div><h4 id="method.from_borrowed_ptr_or_panic" class="method hidden"><code>unsafe fn <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_borrowed_ptr_or_panic" class="fnname">from_borrowed_ptr_or_panic</a>(<br> py: <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'p>, <br> ptr: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyObject.html" title="struct pyo3::ffi::PyObject">PyObject</a><br>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'p </a>Self</code><a class="srclink" href="../../src/pyo3/conversion.rs.html#438-440" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Convert from an arbitrary borrowed <code>PyObject</code>. <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_borrowed_ptr_or_panic">Read more</a></p>
|
||
</div><h4 id="method.from_borrowed_ptr" class="method hidden"><code>unsafe fn <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_borrowed_ptr" class="fnname">from_borrowed_ptr</a>(py: <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'p>, ptr: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyObject.html" title="struct pyo3::ffi::PyObject">PyObject</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'p </a>Self</code><a class="srclink" href="../../src/pyo3/conversion.rs.html#446-448" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Convert from an arbitrary borrowed <code>PyObject</code>. <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_borrowed_ptr">Read more</a></p>
|
||
</div><h4 id="method.from_borrowed_ptr_or_err" class="method hidden"><code>unsafe fn <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_borrowed_ptr_or_err" class="fnname">from_borrowed_ptr_or_err</a>(<br> py: <a class="struct" href="../../pyo3/prelude/struct.Python.html" title="struct pyo3::prelude::Python">Python</a><'p>, <br> ptr: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut </a><a class="struct" href="../../pyo3/ffi/struct.PyObject.html" title="struct pyo3::ffi::PyObject">PyObject</a><br>) -> <a class="type" href="../../pyo3/prelude/type.PyResult.html" title="type pyo3::prelude::PyResult">PyResult</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'p </a>Self></code><a class="srclink" href="../../src/pyo3/conversion.rs.html#454-459" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Convert from an arbitrary borrowed <code>PyObject</code>. <a href="../../pyo3/conversion/trait.FromPyPointer.html#method.from_borrowed_ptr_or_err">Read more</a></p>
|
||
</div></div><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>, </span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#533-540" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#537" 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/mod.rs.html#581-590" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-2" class="type"><code>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-3" class="method hidden"><code>pub 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/mod.rs.html#587" 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/mod.rs.html#567-576" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-3" class="type"><code>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>pub 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/mod.rs.html#573" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
|
||
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="pyo3" data-search-js="../../search-index.js"></div>
|
||
<script src="../../main.js"></script></body></html> |