MCPcopy Index your code
hub / github.com/RustPython/RustPython / count_of

Function count_of

crates/vm/src/stdlib/_operator.rs:179–188  ·  view source on GitHub ↗
(a: PyIter, b: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

177
178 #[pyfunction(name = "countOf")]
179 fn count_of(a: PyIter, b: PyObjectRef, vm: &VirtualMachine) -> PyResult<usize> {
180 let mut count: usize = 0;
181 for element in a.iter_without_hint::<PyObjectRef>(vm)? {
182 let element = element?;
183 if element.is(&b) || vm.bool_eq(&b, &element)? {
184 count += 1;
185 }
186 }
187 Ok(count)
188 }
189
190 #[pyfunction]
191 fn delitem(a: PyObjectRef, b: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {

Callers

nothing calls this directly

Calls 2

isMethod · 0.80
bool_eqMethod · 0.80

Tested by

no test coverage detected