From f354f4ce028cd86b63f33641dc0aa4c53d253274 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Fri, 5 Apr 2019 16:14:02 +0100 Subject: [PATCH] Move contains_key to PyDictRef. --- vm/src/obj/objdict.rs | 6 +++--- vm/src/pyobject.rs | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/vm/src/obj/objdict.rs b/vm/src/obj/objdict.rs index 449c60726..541645d5f 100644 --- a/vm/src/obj/objdict.rs +++ b/vm/src/obj/objdict.rs @@ -206,14 +206,14 @@ impl PyDictRef { fn hash(self, vm: &VirtualMachine) -> PyResult { Err(vm.new_type_error("unhashable type".to_string())) } -} -impl DictProtocol for PyDictRef { - fn contains_key(&self, key: T, vm: &VirtualMachine) -> bool { + pub fn contains_key(&self, key: T, vm: &VirtualMachine) -> bool { let key = key.into_pyobject(vm).unwrap(); self.entries.borrow().contains(vm, &key).unwrap() } +} +impl DictProtocol for PyDictRef { fn get_item(&self, key: T, vm: &VirtualMachine) -> Option { let key = key.into_pyobject(vm).unwrap(); self.entries.borrow().get(vm, &key).ok() diff --git a/vm/src/pyobject.rs b/vm/src/pyobject.rs index 4df7e57fe..bf5cf3c86 100644 --- a/vm/src/pyobject.rs +++ b/vm/src/pyobject.rs @@ -913,7 +913,6 @@ impl TypeProtocol for PyRef { } pub trait DictProtocol { - fn contains_key(&self, key: T, vm: &VirtualMachine) -> bool; fn get_item(&self, key: T, vm: &VirtualMachine) -> Option; fn set_item(&self, key: T, value: PyObjectRef, vm: &VirtualMachine); fn del_item(&self, key: T, vm: &VirtualMachine);