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

Function next

crates/vm/src/stdlib/builtins.rs:896–915  ·  view source on GitHub ↗
(
        iterator: PyObjectRef,
        default_value: OptionalArg<PyObjectRef>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

894
895 #[pyfunction]
896 fn next(
897 iterator: PyObjectRef,
898 default_value: OptionalArg<PyObjectRef>,
899 vm: &VirtualMachine,
900 ) -> PyResult<PyIterReturn> {
901 if !PyIter::check(&iterator) {
902 return Err(vm.new_type_error(format!(
903 "{} object is not an iterator",
904 iterator.class().name()
905 )));
906 }
907 PyIter::new(iterator)
908 .next(vm)
909 .map(|iter_ret| match iter_ret {
910 PyIterReturn::Return(obj) => PyIterReturn::Return(obj),
911 PyIterReturn::StopIteration(v) => {
912 default_value.map_or(PyIterReturn::StopIteration(v), PyIterReturn::Return)
913 }
914 })
915 }
916
917 #[pyfunction]
918 fn oct(number: ArgIndex, vm: &VirtualMachine) -> PyResult {

Callers 15

burstMethod · 0.85
reduceFunction · 0.85
registerFunction · 0.85
_join_translated_partsFunction · 0.85
_parseFunction · 0.85
_get_code_positionFunction · 0.85
_bindMethod · 0.85
venvFunction · 0.85
fmeanFunction · 0.85
_get_code_positionFunction · 0.85
__runMethod · 0.85

Calls 5

newFunction · 0.85
checkFunction · 0.50
ErrClass · 0.50
mapMethod · 0.45
nextMethod · 0.45