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

Method next

crates/vm/src/builtins/set.rs:1400–1421  ·  view source on GitHub ↗
(zelf: &crate::Py<Self>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1398impl SelfIter for PySetIterator {}
1399impl IterNext for PySetIterator {
1400 fn next(zelf: &crate::Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
1401 let mut internal = zelf.internal.lock();
1402 let next = if let IterStatus::Active(dict) = &internal.status {
1403 if dict.has_changed_size(&zelf.size) {
1404 internal.status = IterStatus::Exhausted;
1405 return Err(vm.new_runtime_error("set changed size during iteration"));
1406 }
1407 match dict.next_entry(internal.position) {
1408 Some((position, key, _)) => {
1409 internal.position = position;
1410 PyIterReturn::Return(key)
1411 }
1412 None => {
1413 internal.status = IterStatus::Exhausted;
1414 PyIterReturn::StopIteration(None)
1415 }
1416 }
1417 } else {
1418 PyIterReturn::StopIteration(None)
1419 };
1420 Ok(next)
1421 }
1422}
1423
1424fn vectorcall_set(

Callers

nothing calls this directly

Calls 4

has_changed_sizeMethod · 0.80
next_entryMethod · 0.80
ErrClass · 0.50
lockMethod · 0.45

Tested by

no test coverage detected