MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / index

Method index

src/objects/sequence.rs:201–213  ·  view source on GitHub ↗
(&self, py: Python, value: V)

Source from the content-addressed store, hash-verified

199 /// This is equivalent to the Python expression `o.index(value)`
200 #[inline]
201 pub fn index<V>(&self, py: Python, value: V) -> PyResult<usize>
202 where
203 V: ToPyObject,
204 {
205 let r = value.with_borrowed_ptr(py, |ptr| unsafe {
206 ffi::PySequence_Index(self.as_ptr(), ptr)
207 });
208 if r == -1 {
209 Err(PyErr::fetch(py))
210 } else {
211 Ok(r as usize)
212 }
213 }
214
215 /// Return a fresh list based on the Sequence.
216 #[inline]

Callers

nothing calls this directly

Calls 2

with_borrowed_ptrMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected