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

Method get_index

crates/vm/src/stdlib/_sre.rs:795–812  ·  view source on GitHub ↗
(&self, group: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

793 }
794
795 fn get_index(&self, group: PyObjectRef, vm: &VirtualMachine) -> Option<usize> {
796 let i = if let Ok(i) = group.try_index(vm) {
797 i
798 } else {
799 self.pattern
800 .groupindex
801 .get_item_opt(&*group, vm)
802 .ok()??
803 .downcast::<PyInt>()
804 .ok()?
805 };
806 let i = i.as_bigint().to_isize()?;
807 if i >= 0 && i as usize <= self.pattern.groups {
808 Some(i as usize)
809 } else {
810 None
811 }
812 }
813
814 fn get_slice<S: SreStr>(
815 &self,

Callers 9

getstateMethod · 0.80
spanMethod · 0.80
fold_unary_negativeMethod · 0.80
get_const_value_fromMethod · 0.80
fold_tuple_constantsMethod · 0.80
fold_list_constantsMethod · 0.80
fold_set_constantsMethod · 0.80
get_localsplus_nameMethod · 0.80

Calls 5

try_indexMethod · 0.80
okMethod · 0.80
get_item_optMethod · 0.80
as_bigintMethod · 0.80
SomeClass · 0.50

Tested by

no test coverage detected