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

Method contains

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

Source from the content-addressed store, hash-verified

182 /// Determine if o contains value. this is equivalent to the Python expression `value in o`
183 #[inline]
184 pub fn contains<V>(&self, py: Python, value: V) -> PyResult<bool>
185 where
186 V: ToPyObject,
187 {
188 let r = value.with_borrowed_ptr(py, |ptr| unsafe {
189 ffi::PySequence_Contains(self.as_ptr(), ptr)
190 });
191 match r {
192 0 => Ok(false),
193 1 => Ok(true),
194 _ => Err(PyErr::fetch(py)),
195 }
196 }
197
198 /// Return the first index i for which o[i] == value.
199 /// This is equivalent to the Python expression `o.index(value)`

Callers

nothing calls this directly

Calls 2

with_borrowed_ptrMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected