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

Method _getitem

crates/vm/src/builtins/str.rs:626–632  ·  view source on GitHub ↗
(&self, needle: &PyObject, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

624 }
625
626 fn _getitem(&self, needle: &PyObject, vm: &VirtualMachine) -> PyResult {
627 let item = match SequenceIndex::try_from_borrowed_object(vm, needle, "str")? {
628 SequenceIndex::Int(i) => self.getitem_by_index(vm, i)?.to_pyobject(vm),
629 SequenceIndex::Slice(slice) => self.getitem_by_slice(vm, slice)?.to_pyobject(vm),
630 };
631 Ok(item)
632 }
633
634 fn __getitem__(&self, needle: PyObjectRef, vm: &VirtualMachine) -> PyResult {
635 self._getitem(&needle, vm)

Callers 3

__getitem__Method · 0.45
__getitem__Method · 0.45
__getitem__Method · 0.45

Calls 3

to_pyobjectMethod · 0.45
getitem_by_indexMethod · 0.45
getitem_by_sliceMethod · 0.45

Tested by

no test coverage detected