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

Method call

crates/stdlib/src/json.rs:634–658  ·  view source on GitHub ↗
(zelf: &Py<Self>, (pystr, char_idx): Self::Args, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

632 impl Callable for JsonScanner {
633 type Args = (PyStrRef, isize);
634 fn call(zelf: &Py<Self>, (pystr, char_idx): Self::Args, vm: &VirtualMachine) -> PyResult {
635 if char_idx < 0 {
636 return Err(vm.new_value_error("idx cannot be negative"));
637 }
638 let char_idx = char_idx as usize;
639 let pystr = pystr.try_into_utf8(vm)?;
640 let s = pystr.as_str();
641
642 // Calculate byte index from char index (O(char_idx) but only at entry point)
643 let byte_idx = if char_idx == 0 {
644 0
645 } else {
646 match s.char_indices().nth(char_idx) {
647 Some((byte_i, _)) => byte_i,
648 None => {
649 // char_idx is beyond the string length
650 return PyIterReturn::StopIteration(Some(vm.ctx.new_int(char_idx).into()))
651 .to_pyresult(vm);
652 }
653 }
654 };
655
656 zelf.parse(pystr, char_idx, byte_idx, zelf.to_owned().into(), vm)
657 .and_then(|x| x.to_pyresult(vm))
658 }
659 }
660
661 fn encode_string(s: &str, ascii_only: bool) -> String {

Callers 15

_servername_callbackFunction · 0.45
_msg_callbackFunction · 0.45
load_cert_chainMethod · 0.45
try_from_objectMethod · 0.45
exec_innerFunction · 0.45
bisect_leftFunction · 0.45
bisect_rightFunction · 0.45
insort_leftFunction · 0.45
insort_rightFunction · 0.45
module_execFunction · 0.45
parse_numberMethod · 0.45
finalize_objectMethod · 0.45

Calls 8

try_into_utf8Method · 0.80
ErrClass · 0.50
SomeClass · 0.50
as_strMethod · 0.45
to_pyresultMethod · 0.45
new_intMethod · 0.45
parseMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected