@@ -13,13 +13,13 @@ use crate::{
13
13
function:: Either ,
14
14
function:: { ArgBytesLike , ArgIterable , OptionalArg , OptionalOption , PyComparisonValue } ,
15
15
protocol:: {
16
- BufferDescriptor , BufferMethods , PyBuffer , PyIterReturn , PyMappingMethods ,
16
+ BufferDescriptor , BufferMethods , PyBuffer , PyIterReturn , PyMappingMethods , PyNumberMethods ,
17
17
PySequenceMethods ,
18
18
} ,
19
19
sliceable:: { SequenceIndex , SliceableSequenceOp } ,
20
20
types:: {
21
- AsBuffer , AsMapping , AsSequence , Callable , Comparable , Constructor , Hashable , IterNext ,
22
- IterNextIterable , Iterable , PyComparisonOp , Unconstructible ,
21
+ AsBuffer , AsMapping , AsNumber , AsSequence , Callable , Comparable , Constructor , Hashable ,
22
+ IterNext , IterNextIterable , Iterable , PyComparisonOp , Unconstructible ,
23
23
} ,
24
24
AsObject , Context , Py , PyObject , PyObjectRef , PyPayload , PyRef , PyResult ,
25
25
TryFromBorrowedObject , TryFromObject , VirtualMachine ,
@@ -108,7 +108,8 @@ impl PyBytes {
108
108
Comparable ,
109
109
AsBuffer ,
110
110
Iterable ,
111
- Constructor
111
+ Constructor ,
112
+ AsNumber
112
113
)
113
114
) ]
114
115
impl PyBytes {
@@ -606,6 +607,17 @@ impl AsSequence for PyBytes {
606
607
} ;
607
608
}
608
609
610
+ impl AsNumber for PyBytes {
611
+ const AS_NUMBER : PyNumberMethods =PyNumberMethods {
612
+ remainder : Some ( |number, other, vm|{
613
+ Self :: number_downcast ( number)
614
+ . mod_ ( other. to_owned ( ) , vm)
615
+ . to_pyresult ( vm)
616
+ } ) ,
617
+ ..PyNumberMethods :: NOT_IMPLEMENTED
618
+ } ;
619
+ }
620
+
609
621
impl Hashable for PyBytes {
610
622
#[ inline]
611
623
fn hash ( zelf : & crate :: Py < Self > , vm : & VirtualMachine ) ->PyResult < PyHash > {