@@ -194,41 +194,37 @@ impl PyNumberMethods {
194194 inplace_matrix_multiply : None ,
195195 } ;
196196
197- pub fn get_binary_op (
198- & self ,
199- op_slot : PyNumberBinaryOp ,
200- ) -> PyResult < & Option < PyNumberBinaryFunc > > {
197+ pub fn binary_op ( & self , op_slot : PyNumberBinaryOp ) -> Option < PyNumberBinaryFunc > {
201198 use PyNumberBinaryOp :: * ;
202- let binary_op = match op_slot {
203- Add => & self . add ,
204- Subtract => & self . subtract ,
205- Multiply => & self . multiply ,
206- Remainder => & self . remainder ,
207- Divmod => & self . divmod ,
208- Power => & self . power ,
209- Lshift => & self . lshift ,
210- Rshift => & self . rshift ,
211- And => & self . and ,
212- Xor => & self . xor ,
213- Or => & self . or ,
214- InplaceAdd => & self . inplace_add ,
215- InplaceSubtract => & self . inplace_subtract ,
216- InplaceMultiply => & self . inplace_multiply ,
217- InplaceRemainder => & self . inplace_remainder ,
218- InplacePower => & self . inplace_power ,
219- InplaceLshift => & self . inplace_lshift ,
220- InplaceRshift => & self . inplace_rshift ,
221- InplaceAnd => & self . inplace_and ,
222- InplaceXor => & self . inplace_xor ,
223- InplaceOr => & self . inplace_or ,
224- FloorDivide => & self . floor_divide ,
225- TrueDivide => & self . true_divide ,
226- InplaceFloorDivide => & self . inplace_floor_divide ,
227- InplaceTrueDivide => & self . inplace_true_divide ,
228- MatrixMultiply => & self . matrix_multiply ,
229- InplaceMatrixMultiply => & self . inplace_matrix_multiply ,
230- } ;
231- Ok ( binary_op)
199+ match op_slot {
200+ Add => self . add ,
201+ Subtract => self . subtract ,
202+ Multiply => self . multiply ,
203+ Remainder => self . remainder ,
204+ Divmod => self . divmod ,
205+ Power => self . power ,
206+ Lshift => self . lshift ,
207+ Rshift => self . rshift ,
208+ And => self . and ,
209+ Xor => self . xor ,
210+ Or => self . or ,
211+ InplaceAdd => self . inplace_add ,
212+ InplaceSubtract => self . inplace_subtract ,
213+ InplaceMultiply => self . inplace_multiply ,
214+ InplaceRemainder => self . inplace_remainder ,
215+ InplacePower => self . inplace_power ,
216+ InplaceLshift => self . inplace_lshift ,
217+ InplaceRshift => self . inplace_rshift ,
218+ InplaceAnd => self . inplace_and ,
219+ InplaceXor => self . inplace_xor ,
220+ InplaceOr => self . inplace_or ,
221+ FloorDivide => self . floor_divide ,
222+ TrueDivide => self . true_divide ,
223+ InplaceFloorDivide => self . inplace_floor_divide ,
224+ InplaceTrueDivide => self . inplace_true_divide ,
225+ MatrixMultiply => self . matrix_multiply ,
226+ InplaceMatrixMultiply => self . inplace_matrix_multiply ,
227+ }
232228 }
233229}
234230
@@ -266,7 +262,7 @@ pub enum PyNumberBinaryOp {
266262#[ derive( Copy , Clone ) ]
267263pub struct PyNumber < ' a > {
268264 pub obj : & ' a PyObject ,
269- methods : & ' a PyNumberMethods ,
265+ pub ( crate ) methods : & ' a PyNumberMethods ,
270266}
271267
272268impl < ' a > From < & ' a PyObject > for PyNumber < ' a > {
@@ -285,17 +281,6 @@ impl PyNumber<'_> {
285281 obj. class ( ) . mro_find_map ( |x| x. slots . as_number . load ( ) )
286282 }
287283
288- pub fn methods ( & self ) -> & PyNumberMethods {
289- self . methods
290- }
291-
292- pub fn get_binary_op (
293- & self ,
294- op_slot : PyNumberBinaryOp ,
295- ) -> PyResult < & Option < PyNumberBinaryFunc > > {
296- self . methods ( ) . get_binary_op ( op_slot)
297- }
298-
299284 // PyNumber_Check
300285 pub fn check ( obj : & PyObject ) -> bool {
301286 let methods = & obj. class ( ) . slots . number ;
0 commit comments