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

Method count

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

Source from the content-addressed store, hash-verified

166 /// which `o[key] == value`
167 #[inline]
168 pub fn count<V>(&self, py: Python, value: V) -> PyResult<usize>
169 where
170 V: ToPyObject,
171 {
172 let r = value.with_borrowed_ptr(py, |ptr| unsafe {
173 ffi::PySequence_Count(self.as_ptr(), ptr)
174 });
175 if r == -1 {
176 Err(PyErr::fetch(py))
177 } else {
178 Ok(r as usize)
179 }
180 }
181
182 /// Determine if o contains value. this is equivalent to the Python expression `value in o`
183 #[inline]

Callers

nothing calls this directly

Calls 2

with_borrowed_ptrMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected