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

Method update_internal

crates/vm/src/builtins/set.rs:368–382  ·  view source on GitHub ↗
(&self, iterable: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

366 }
367
368 fn update_internal(&self, iterable: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
369 // check AnySet
370 if let Ok(any_set) = AnySet::try_from_object(vm, iterable.to_owned()) {
371 self.merge_set(any_set, vm)
372 // check Dict
373 } else if let Ok(dict) = iterable.to_owned().downcast_exact::<PyDict>(vm) {
374 self.merge_dict(dict.into_pyref(), vm)
375 } else {
376 // add iterable that is not AnySet or Dict
377 for item in iterable.try_into_value::<ArgIterable>(vm)?.iter(vm)? {
378 self.add(item?, vm)?;
379 }
380 Ok(())
381 }
382 }
383
384 fn merge_set(&self, any_set: AnySet, vm: &VirtualMachine) -> PyResult<()> {
385 for item in any_set.as_inner().elements() {

Callers 1

updateMethod · 0.80

Calls 6

merge_setMethod · 0.80
into_pyrefMethod · 0.80
to_ownedMethod · 0.45
merge_dictMethod · 0.45
iterMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected