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

Method to_attributes

crates/vm/src/builtins/dict.rs:650–657  ·  view source on GitHub ↗

Take a python dictionary and convert it to attributes.

(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

648
649 /// Take a python dictionary and convert it to attributes.
650 pub fn to_attributes(&self, vm: &VirtualMachine) -> PyAttributes {
651 let mut attrs = PyAttributes::default();
652 for (key, value) in self {
653 let key: PyRefExact<PyStr> = key.downcast_exact(vm).expect("dict has non-string keys");
654 attrs.insert(vm.ctx.intern_str(key), value);
655 }
656 attrs
657 }
658
659 pub fn get_item_opt<K: DictKey + ?Sized>(
660 &self,

Callers 2

start_new_threadFunction · 0.80
slot_newMethod · 0.80

Calls 3

downcast_exactMethod · 0.80
intern_strMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected