@@ -2,9 +2,9 @@ use super::{PyDict, PyDictRef, PyGenericAlias, PyList, PyTuple, PyType, PyTypeRe
2
2
use crate :: {
3
3
class:: PyClassImpl ,
4
4
convert:: ToPyObject ,
5
- function:: { ArgMapping , OptionalArg } ,
5
+ function:: { ArgMapping , OptionalArg , PyComparisonValue } ,
6
6
protocol:: { PyMapping , PyMappingMethods , PyNumberMethods , PySequence , PySequenceMethods } ,
7
- types:: { AsMapping , AsNumber , AsSequence , Constructor , Iterable } ,
7
+ types:: { AsMapping , AsNumber , AsSequence , Comparable , Constructor , Iterable , PyComparisonOp } ,
8
8
AsObject , Context , Py , PyObject , PyObjectRef , PyPayload , PyRef , PyResult , VirtualMachine ,
9
9
} ;
10
10
@@ -64,7 +64,7 @@ impl Constructor for PyMappingProxy {
64
64
}
65
65
}
66
66
67
- #[ pyimpl( with( AsMapping , Iterable , Constructor , AsSequence ) ) ]
67
+ #[ pyimpl( with( AsMapping , Iterable , Constructor , AsSequence , Comparable ) ) ]
68
68
impl PyMappingProxy {
69
69
fn get_inner ( & self , key : PyObjectRef , vm : & VirtualMachine ) -> PyResult < Option < PyObjectRef > > {
70
70
let opt = match & self . mapping {
@@ -185,6 +185,20 @@ impl PyMappingProxy {
185
185
}
186
186
}
187
187
188
+ impl Comparable for PyMappingProxy {
189
+ fn cmp (
190
+ zelf : & crate :: Py < Self > ,
191
+ other : & PyObject ,
192
+ op : PyComparisonOp ,
193
+ vm : & VirtualMachine ,
194
+ ) -> PyResult < PyComparisonValue > {
195
+ let obj = zelf. to_object ( vm) ?;
196
+ Ok ( PyComparisonValue :: Implemented (
197
+ obj. rich_compare_bool ( other, op, vm) ?,
198
+ ) )
199
+ }
200
+ }
201
+
188
202
impl AsMapping for PyMappingProxy {
189
203
const AS_MAPPING : PyMappingMethods = PyMappingMethods {
190
204
length : Some ( |mapping, vm| Self :: mapping_downcast ( mapping) . len ( vm) ) ,
0 commit comments