Files
google_speech_rs/docs/pyo3/prelude/trait.PyListMethods.html
2025-04-02 13:41:38 +00:00

95 lines
33 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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="Implementation of functionality for `PyList`."><title>PyListMethods in pyo3::prelude - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-46132b98.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="pyo3" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.1 (4eb161250 2025-03-15)" data-channel="1.85.1" data-search-js="search-75f5ac3e.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../pyo3/index.html">pyo3</a><span class="version">0.24.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">PyList<wbr>Methods</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.append" title="append">append</a></li><li><a href="#tymethod.as_sequence" title="as_sequence">as_sequence</a></li><li><a href="#tymethod.contains" title="contains">contains</a></li><li><a href="#tymethod.del_item" title="del_item">del_item</a></li><li><a href="#tymethod.del_slice" title="del_slice">del_slice</a></li><li><a href="#tymethod.get_item" title="get_item">get_item</a></li><li><a href="#tymethod.get_item_unchecked" title="get_item_unchecked">get_item_unchecked</a></li><li><a href="#tymethod.get_slice" title="get_slice">get_slice</a></li><li><a href="#tymethod.index" title="index">index</a></li><li><a href="#tymethod.insert" title="insert">insert</a></li><li><a href="#tymethod.into_sequence" title="into_sequence">into_sequence</a></li><li><a href="#tymethod.is_empty" title="is_empty">is_empty</a></li><li><a href="#tymethod.iter" title="iter">iter</a></li><li><a href="#tymethod.len" title="len">len</a></li><li><a href="#tymethod.locked_for_each" title="locked_for_each">locked_for_each</a></li><li><a href="#tymethod.reverse" title="reverse">reverse</a></li><li><a href="#tymethod.set_item" title="set_item">set_item</a></li><li><a href="#tymethod.set_slice" title="set_slice">set_slice</a></li><li><a href="#tymethod.sort" title="sort">sort</a></li><li><a href="#tymethod.to_tuple" title="to_tuple">to_tuple</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In pyo3::<wbr>prelude</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">pyo3</a>::<wbr><a href="index.html">prelude</a></span><h1>Trait <span class="trait">PyListMethods</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/pyo3/types/list.rs.html#152-265">Source</a> </span></div><pre class="rust item-decl"><code>pub trait PyListMethods&lt;'py&gt;: Sealed {
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 20 methods</span></summary> // Required methods
fn <a href="#tymethod.len" class="fn">len</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.bool.html">bool</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.as_sequence" class="fn">as_sequence</a>(&amp;self) -&gt; &amp;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PySequence.html" title="struct pyo3::types::PySequence">PySequence</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.into_sequence" class="fn">into_sequence</a>(self) -&gt; <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PySequence.html" title="struct pyo3::types::PySequence">PySequence</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.get_item" class="fn">get_item</a>(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;&gt;;
<span class="item-spacer"></span> unsafe fn <a href="#tymethod.get_item_unchecked" class="fn">get_item_unchecked</a>(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.get_slice" class="fn">get_slice</a>(&amp;self, low: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>, high: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyList.html" title="struct pyo3::types::PyList">PyList</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.set_item" class="fn">set_item</a>&lt;I&gt;(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>, item: I) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;
<span class="where">where I: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;</span>;
<span class="item-spacer"></span> fn <a href="#tymethod.del_item" class="fn">del_item</a>(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.set_slice" class="fn">set_slice</a>(
&amp;self,
low: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>,
high: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>,
seq: &amp;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'_, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;,
) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.del_slice" class="fn">del_slice</a>(&amp;self, low: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>, high: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.append" class="fn">append</a>&lt;I&gt;(&amp;self, item: I) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;
<span class="where">where I: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;</span>;
<span class="item-spacer"></span> fn <a href="#tymethod.insert" class="fn">insert</a>&lt;I&gt;(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>, item: I) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;
<span class="where">where I: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;</span>;
<span class="item-spacer"></span> fn <a href="#tymethod.contains" class="fn">contains</a>&lt;V&gt;(&amp;self, value: V) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.bool.html">bool</a>&gt;
<span class="where">where V: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;</span>;
<span class="item-spacer"></span> fn <a href="#tymethod.index" class="fn">index</a>&lt;V&gt;(&amp;self, value: V) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>&gt;
<span class="where">where V: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;</span>;
<span class="item-spacer"></span> fn <a href="#tymethod.iter" class="fn">iter</a>(&amp;self) -&gt; <a class="struct" href="../types/iter/struct.BoundListIterator.html" title="struct pyo3::types::iter::BoundListIterator">BoundListIterator</a>&lt;'py&gt; <a href="#" class="tooltip" data-notable-ty="BoundListIterator&lt;&#39;py&gt;"></a>;
<span class="item-spacer"></span> fn <a href="#tymethod.locked_for_each" class="fn">locked_for_each</a>&lt;F&gt;(&amp;self, closure: F) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;
<span class="where">where F: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</span>;
<span class="item-spacer"></span> fn <a href="#tymethod.sort" class="fn">sort</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.reverse" class="fn">reverse</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.to_tuple" class="fn">to_tuple</a>(&amp;self) -&gt; <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyTuple.html" title="struct pyo3::types::PyTuple">PyTuple</a>&gt;;
</details>}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implementation of functionality for <a href="../types/struct.PyList.html" title="struct pyo3::types::PyList"><code>PyList</code></a>.</p>
<p>These methods are defined for the <code>Bound&lt;'py, PyList&gt;</code> smart pointer, so to use method call
syntax these methods are separated into a trait, because stable Rust does not yet support
<code>arbitrary_self_types</code>.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.len" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#154">Source</a><h4 class="code-header">fn <a href="#tymethod.len" class="fn">len</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a></h4></section></summary><div class="docblock"><p>Returns the length of the list.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.is_empty" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#157">Source</a><h4 class="code-header">fn <a href="#tymethod.is_empty" class="fn">is_empty</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Checks if the list is empty.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.as_sequence" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#160">Source</a><h4 class="code-header">fn <a href="#tymethod.as_sequence" class="fn">as_sequence</a>(&amp;self) -&gt; &amp;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PySequence.html" title="struct pyo3::types::PySequence">PySequence</a>&gt;</h4></section></summary><div class="docblock"><p>Returns <code>self</code> cast as a <code>PySequence</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.into_sequence" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#163">Source</a><h4 class="code-header">fn <a href="#tymethod.into_sequence" class="fn">into_sequence</a>(self) -&gt; <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PySequence.html" title="struct pyo3::types::PySequence">PySequence</a>&gt;</h4></section></summary><div class="docblock"><p>Returns <code>self</code> cast as a <code>PySequence</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.get_item" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#175">Source</a><h4 class="code-header">fn <a href="#tymethod.get_item" class="fn">get_item</a>(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;&gt;</h4></section></summary><div class="docblock"><p>Gets the list item at the specified index.</p>
<h5 id="example"><a class="doc-anchor" href="#example">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>pyo3::{prelude::<span class="kw-2">*</span>, types::PyList};
Python::with_gil(|py| {
<span class="kw">let </span>list = PyList::new(py, [<span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>]).unwrap();
<span class="kw">let </span>obj = list.get_item(<span class="number">0</span>);
<span class="macro">assert_eq!</span>(obj.unwrap().extract::&lt;i32&gt;().unwrap(), <span class="number">2</span>);
});</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.get_item_unchecked" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#185">Source</a><h4 class="code-header">unsafe fn <a href="#tymethod.get_item_unchecked" class="fn">get_item_unchecked</a>(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;</h4></section></summary><div class="docblock"><p>Gets the list item at the specified index. Undefined behavior on bad index. Use with caution.</p>
<h5 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h5>
<p>Caller must verify that the index is within the bounds of the list.
On the free-threaded build, caller must verify they have exclusive access to the list
via a lock or by holding the innermost critical section on the list.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.get_slice" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#191">Source</a><h4 class="code-header">fn <a href="#tymethod.get_slice" class="fn">get_slice</a>(&amp;self, low: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>, high: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyList.html" title="struct pyo3::types::PyList">PyList</a>&gt;</h4></section></summary><div class="docblock"><p>Takes the slice <code>self[low:high]</code> and returns it as a new list.</p>
<p>Indices must be nonnegative, and out-of-range indices are clipped to
<code>self.len()</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.set_item" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#196-198">Source</a><h4 class="code-header">fn <a href="#tymethod.set_item" class="fn">set_item</a>&lt;I&gt;(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>, item: I) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;<div class="where">where
I: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;,</div></h4></section></summary><div class="docblock"><p>Sets the item at the specified index.</p>
<p>Raises <code>IndexError</code> if the index is out of range.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.del_item" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#203">Source</a><h4 class="code-header">fn <a href="#tymethod.del_item" class="fn">del_item</a>(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Deletes the <code>index</code>th element of self.</p>
<p>This is equivalent to the Python statement <code>del self[i]</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.set_slice" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#208">Source</a><h4 class="code-header">fn <a href="#tymethod.set_slice" class="fn">set_slice</a>(
&amp;self,
low: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>,
high: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>,
seq: &amp;<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'_, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;,
) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Assigns the sequence <code>seq</code> to the slice of <code>self</code> from <code>low</code> to <code>high</code>.</p>
<p>This is equivalent to the Python statement <code>self[low:high] = v</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.del_slice" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#213">Source</a><h4 class="code-header">fn <a href="#tymethod.del_slice" class="fn">del_slice</a>(&amp;self, low: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>, high: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Deletes the slice from <code>low</code> to <code>high</code> from <code>self</code>.</p>
<p>This is equivalent to the Python statement <code>del self[low:high]</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.append" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#216-218">Source</a><h4 class="code-header">fn <a href="#tymethod.append" class="fn">append</a>&lt;I&gt;(&amp;self, item: I) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;<div class="where">where
I: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;,</div></h4></section></summary><div class="docblock"><p>Appends an item to the list.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.insert" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#223-225">Source</a><h4 class="code-header">fn <a href="#tymethod.insert" class="fn">insert</a>&lt;I&gt;(&amp;self, index: <a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>, item: I) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;<div class="where">where
I: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;,</div></h4></section></summary><div class="docblock"><p>Inserts an item at the specified index.</p>
<p>If <code>index &gt;= self.len()</code>, inserts at the end.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.contains" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#230-232">Source</a><h4 class="code-header">fn <a href="#tymethod.contains" class="fn">contains</a>&lt;V&gt;(&amp;self, value: V) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.bool.html">bool</a>&gt;<div class="where">where
V: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;,</div></h4></section></summary><div class="docblock"><p>Determines if self contains <code>value</code>.</p>
<p>This is equivalent to the Python expression <code>value in self</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.index" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#237-239">Source</a><h4 class="code-header">fn <a href="#tymethod.index" class="fn">index</a>&lt;V&gt;(&amp;self, value: V) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.usize.html">usize</a>&gt;<div class="where">where
V: <a class="trait" href="../conversion/trait.IntoPyObject.html" title="trait pyo3::conversion::IntoPyObject">IntoPyObject</a>&lt;'py&gt;,</div></h4></section></summary><div class="docblock"><p>Returns the first index <code>i</code> for which <code>self[i] == value</code>.</p>
<p>This is equivalent to the Python expression <code>self.index(value)</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.iter" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#242">Source</a><h4 class="code-header">fn <a href="#tymethod.iter" class="fn">iter</a>(&amp;self) -&gt; <a class="struct" href="../types/iter/struct.BoundListIterator.html" title="struct pyo3::types::iter::BoundListIterator">BoundListIterator</a>&lt;'py&gt; <a href="#" class="tooltip" data-notable-ty="BoundListIterator&lt;&#39;py&gt;"></a></h4></section></summary><div class="docblock"><p>Returns an iterator over this lists items.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.locked_for_each" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#251-253">Source</a><h4 class="code-header">fn <a href="#tymethod.locked_for_each" class="fn">locked_for_each</a>&lt;F&gt;(&amp;self, closure: F) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;<div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/1.85.1/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(<a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyAny.html" title="struct pyo3::types::PyAny">PyAny</a>&gt;) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;,</div></h4></section></summary><div class="docblock"><p>Iterates over the contents of this list while holding a critical section on the list.
This is useful when the GIL is disabled and the list is shared between threads.
It is not guaranteed that the list will not be modified during iteration when the
closure calls arbitrary Python code that releases the critical section held by the
iterator. Otherwise, the list will not be modified during iteration.</p>
<p>This is equivalent to for_each if the GIL is enabled.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.sort" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#256">Source</a><h4 class="code-header">fn <a href="#tymethod.sort" class="fn">sort</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Sorts the list in-place. Equivalent to the Python expression <code>l.sort()</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.reverse" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#259">Source</a><h4 class="code-header">fn <a href="#tymethod.reverse" class="fn">reverse</a>(&amp;self) -&gt; <a class="type" href="../type.PyResult.html" title="type pyo3::PyResult">PyResult</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.85.1/std/primitive.unit.html">()</a>&gt;</h4></section></summary><div class="docblock"><p>Reverses the list in-place. Equivalent to the Python expression <code>l.reverse()</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.to_tuple" class="method"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#264">Source</a><h4 class="code-header">fn <a href="#tymethod.to_tuple" class="fn">to_tuple</a>(&amp;self) -&gt; <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyTuple.html" title="struct pyo3::types::PyTuple">PyTuple</a>&gt;</h4></section></summary><div class="docblock"><p>Return a new tuple containing the contents of the list; equivalent to the Python expression <code>tuple(list)</code>.</p>
<p>This method is equivalent to <code>self.as_sequence().to_tuple()</code> and faster than <code>PyTuple::new(py, this_list)</code>.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.85.1/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-PyListMethods%3C'py%3E-for-Bound%3C'py,+PyList%3E" class="impl"><a class="src rightside" href="../../src/pyo3/types/list.rs.html#267-486">Source</a><a href="#impl-PyListMethods%3C'py%3E-for-Bound%3C'py,+PyList%3E" class="anchor">§</a><h3 class="code-header">impl&lt;'py&gt; <a class="trait" href="../types/trait.PyListMethods.html" title="trait pyo3::types::PyListMethods">PyListMethods</a>&lt;'py&gt; for <a class="struct" href="../struct.Bound.html" title="struct pyo3::Bound">Bound</a>&lt;'py, <a class="struct" href="../types/struct.PyList.html" title="struct pyo3::types::PyList">PyList</a>&gt;</h3></section></div><script src="../../trait.impl/pyo3/types/list/trait.PyListMethods.js" async></script><script type="text/json" id="notable-traits-data">{"BoundListIterator<'py>":"<h3>Notable traits for <code><a class=\"struct\" href=\"../types/iter/struct.BoundListIterator.html\" title=\"struct pyo3::types::iter::BoundListIterator\">BoundListIterator</a>&lt;'py&gt;</code></h3><pre><code><div class=\"where\">impl&lt;'py&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.85.1/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"../types/iter/struct.BoundListIterator.html\" title=\"struct pyo3::types::iter::BoundListIterator\">BoundListIterator</a>&lt;'py&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.85.1/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = <a class=\"struct\" href=\"../struct.Bound.html\" title=\"struct pyo3::Bound\">Bound</a>&lt;'py, <a class=\"struct\" href=\"../types/struct.PyAny.html\" title=\"struct pyo3::types::PyAny\">PyAny</a>&gt;;</div>"}</script></section></div></main></body></html>