implement hashable and unhashable for collections.deque

This commit is contained in:
James Webber
2021-08-08 20:59:39 -04:00
parent 9652c79f1d
commit e003f255d5

View File

@@ -5,7 +5,7 @@ mod _collections {
use crate::builtins::pytype::PyTypeRef;
use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
use crate::function::OptionalArg;
use crate::slots::{Comparable, Iterable, PyComparisonOp, PyIter};
use crate::slots::{Comparable, Hashable, Iterable, PyComparisonOp, PyIter, Unhashable};
use crate::vm::ReprGuard;
use crate::VirtualMachine;
use crate::{sequence, sliceable};
@@ -64,7 +64,7 @@ mod _collections {
}
}
#[pyimpl(flags(BASETYPE), with(Comparable, Iterable))]
#[pyimpl(flags(BASETYPE), with(Comparable, Hashable, Iterable))]
impl PyDeque {
#[pyslot]
fn tp_new(
@@ -340,6 +340,8 @@ mod _collections {
}
}
impl Unhashable for PyDeque {}
impl Iterable for PyDeque {
fn iter(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult {
Ok(PyDequeIterator {