mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
Implement IntoIterator for PyDictRef.
This commit is contained in:
@@ -17,11 +17,7 @@ impl PyValue for PyModule {
|
||||
impl PyModuleRef {
|
||||
fn dir(self: PyModuleRef, vm: &VirtualMachine) -> PyResult {
|
||||
if let Some(dict) = &self.into_object().dict {
|
||||
let keys = dict
|
||||
.get_key_value_pairs()
|
||||
.iter()
|
||||
.map(|(k, _v)| k.clone())
|
||||
.collect();
|
||||
let keys = dict.into_iter().map(|(k, _v)| k.clone()).collect();
|
||||
Ok(vm.ctx.new_list(keys))
|
||||
} else {
|
||||
panic!("Modules should definitely have a dict.");
|
||||
|
||||
Reference in New Issue
Block a user