@@ -588,16 +588,6 @@ impl PyContext {
588
588
)
589
589
}
590
590
591
- pub fn new_rustfunc_from_box (
592
- & self ,
593
- function : Box < Fn ( & mut VirtualMachine , PyFuncArgs ) -> PyResult > ,
594
- ) -> PyObjectRef {
595
- PyObject :: new (
596
- PyObjectPayload :: RustFunction { function } ,
597
- self . builtin_function_or_method_type ( ) ,
598
- )
599
- }
600
-
601
591
pub fn new_frame ( & self , code : PyObjectRef , scope : PyObjectRef ) -> PyObjectRef {
602
592
PyObject :: new (
603
593
PyObjectPayload :: Frame {
@@ -1242,7 +1232,7 @@ tuple_from_py_func_args!(A, B, C);
1242
1232
tuple_from_py_func_args ! ( A , B , C , D ) ;
1243
1233
tuple_from_py_func_args ! ( A , B , C , D , E ) ;
1244
1234
1245
- pub type PyNativeFunc = Box < dyn Fn ( & mut VirtualMachine , PyFuncArgs ) -> PyResult > ;
1235
+ pub type PyNativeFunc = Box < dyn Fn ( & mut VirtualMachine , PyFuncArgs ) -> PyResult + ' static > ;
1246
1236
1247
1237
pub trait PyNativeFuncFactory < T , R > {
1248
1238
fn create ( self ) -> PyNativeFunc ;
@@ -1257,6 +1247,12 @@ where
1257
1247
}
1258
1248
}
1259
1249
1250
+ impl PyNativeFuncFactory < PyFuncArgs , PyResult > for PyNativeFunc {
1251
+ fn create ( self ) -> PyNativeFunc {
1252
+ self
1253
+ }
1254
+ }
1255
+
1260
1256
macro_rules! py_native_func_factory_tuple {
1261
1257
( $( ( $n: tt, $T: ident) ) ,+) => {
1262
1258
impl <F , $( $T, ) + R > PyNativeFuncFactory <( $( $T, ) +) , R > for F
@@ -1378,7 +1374,7 @@ pub enum PyObjectPayload {
1378
1374
dict : RefCell < PyAttributes > ,
1379
1375
} ,
1380
1376
RustFunction {
1381
- function : Box < Fn ( & mut VirtualMachine , PyFuncArgs ) -> PyResult > ,
1377
+ function : PyNativeFunc ,
1382
1378
} ,
1383
1379
Socket {
1384
1380
socket : RefCell < Socket > ,
0 commit comments