Move contains_key to PyDictRef.

This commit is contained in:
Adam Kelly
2019-04-05 16:14:02 +01:00
parent 0dce9bb96a
commit f354f4ce02
2 changed files with 3 additions and 4 deletions

View File

@@ -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<T: IntoPyObject>(&self, key: T, vm: &VirtualMachine) -> bool {
pub fn contains_key<T: IntoPyObject>(&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<T: IntoPyObject>(&self, key: T, vm: &VirtualMachine) -> Option<PyObjectRef> {
let key = key.into_pyobject(vm).unwrap();
self.entries.borrow().get(vm, &key).ok()

View File

@@ -913,7 +913,6 @@ impl<T> TypeProtocol for PyRef<T> {
}
pub trait DictProtocol {
fn contains_key<T: IntoPyObject>(&self, key: T, vm: &VirtualMachine) -> bool;
fn get_item<T: IntoPyObject>(&self, key: T, vm: &VirtualMachine) -> Option<PyObjectRef>;
fn set_item<T: IntoPyObject>(&self, key: T, value: PyObjectRef, vm: &VirtualMachine);
fn del_item<T: IntoPyObject>(&self, key: T, vm: &VirtualMachine);