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

Function index_of

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

Source from the content-addressed store, hash-verified

199
200 #[pyfunction(name = "indexOf")]
201 fn index_of(a: PyIter, b: PyObjectRef, vm: &VirtualMachine) -> PyResult<usize> {
202 for (index, element) in a.iter_without_hint::<PyObjectRef>(vm)?.enumerate() {
203 let element = element?;
204 if element.is(&b) || vm.bool_eq(&b, &element)? {
205 return Ok(index);
206 }
207 }
208 Err(vm.new_value_error("sequence.index(x): x not in sequence"))
209 }
210
211 #[pyfunction]
212 fn setitem(

Callers

nothing calls this directly

Calls 3

isMethod · 0.80
bool_eqMethod · 0.80
ErrClass · 0.50

Tested by

no test coverage detected