[−][src]Type Definition rustpython_vm::obj::objdict::PyDictRef
type PyDictRef = PyRef<PyDict>;
Methods
impl PyDictRef
[src][−]
pub fn copy(self) -> PyDict
[src]
pub fn to_attributes(self) -> PyAttributes
[src][−]
Take a python dictionary and convert it to attributes.
pub fn from_attributes(
attrs: PyAttributes,
vm: &VirtualMachine
) -> PyResult<Self>
[src]
attrs: PyAttributes,
vm: &VirtualMachine
) -> PyResult<Self>
pub fn contains_key<T: IntoPyObject>(&self, key: T, vm: &VirtualMachine) -> bool
[src]
pub fn size(&self) -> DictSize
[src]
pub fn get_item_option<T: IntoPyObject + DictKey + Copy>(
&self,
key: T,
vm: &VirtualMachine
) -> PyResult<Option<PyObjectRef>>
[src][−]
&self,
key: T,
vm: &VirtualMachine
) -> PyResult<Option<PyObjectRef>>
This function can be used to get an item without raising the KeyError, so we can simply check upon the result being Some python value, or None. Note that we can pass any type which implements the DictKey trait. Notable examples are String and PyObjectRef.