mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
Move contains_key to PyDictRef.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user