@@ -576,13 +576,13 @@ impl PyContext {
576
576
)
577
577
}
578
578
579
- pub fn new_rustfunc < F , T , R > ( & self , factory : F ) -> PyObjectRef
579
+ pub fn new_rustfunc < F , T , R > ( & self , f : F ) -> PyObjectRef
580
580
where
581
- F : PyNativeFuncFactory < T , R > ,
581
+ F : IntoPyNativeFunc < T , R > ,
582
582
{
583
583
PyObject :: new (
584
584
PyObjectPayload :: RustFunction {
585
- function : factory . create ( ) ,
585
+ function : f . into_func ( ) ,
586
586
} ,
587
587
self . builtin_function_or_method_type ( ) ,
588
588
)
@@ -1234,35 +1234,35 @@ tuple_from_py_func_args!(A, B, C, D, E);
1234
1234
1235
1235
pub type PyNativeFunc = Box < dyn Fn ( & mut VirtualMachine , PyFuncArgs ) -> PyResult + ' static > ;
1236
1236
1237
- pub trait PyNativeFuncFactory < T , R > {
1238
- fn create ( self ) -> PyNativeFunc ;
1237
+ pub trait IntoPyNativeFunc < T , R > {
1238
+ fn into_func ( self ) -> PyNativeFunc ;
1239
1239
}
1240
1240
1241
- impl < F > PyNativeFuncFactory < PyFuncArgs , PyResult > for F
1241
+ impl < F > IntoPyNativeFunc < PyFuncArgs , PyResult > for F
1242
1242
where
1243
1243
F : Fn ( & mut VirtualMachine , PyFuncArgs ) -> PyResult + ' static ,
1244
1244
{
1245
- fn create ( self ) -> PyNativeFunc {
1245
+ fn into_func ( self ) -> PyNativeFunc {
1246
1246
Box :: new ( self )
1247
1247
}
1248
1248
}
1249
1249
1250
- impl PyNativeFuncFactory < PyFuncArgs , PyResult > for PyNativeFunc {
1251
- fn create ( self ) -> PyNativeFunc {
1250
+ impl IntoPyNativeFunc < PyFuncArgs , PyResult > for PyNativeFunc {
1251
+ fn into_func ( self ) -> PyNativeFunc {
1252
1252
self
1253
1253
}
1254
1254
}
1255
1255
1256
- macro_rules! py_native_func_factory_tuple {
1256
+ macro_rules! into_py_native_func_tuple {
1257
1257
( $( ( $n: tt, $T: ident) ) ,+) => {
1258
- impl <F , $( $T, ) + R > PyNativeFuncFactory <( $( $T, ) +) , R > for F
1258
+ impl <F , $( $T, ) + R > IntoPyNativeFunc <( $( $T, ) +) , R > for F
1259
1259
where
1260
1260
F : Fn ( $( $T, ) + & mut VirtualMachine ) -> R + ' static ,
1261
1261
$( $T: FromArgs , ) +
1262
1262
( $( $T, ) +) : FromArgs ,
1263
1263
R : IntoPyObject ,
1264
1264
{
1265
- fn create ( self ) -> PyNativeFunc {
1265
+ fn into_func ( self ) -> PyNativeFunc {
1266
1266
Box :: new( move |vm, args| {
1267
1267
let ( $( $n, ) +) = args. bind:: <( $( $T, ) +) >( vm) ?;
1268
1268
@@ -1273,11 +1273,11 @@ macro_rules! py_native_func_factory_tuple {
1273
1273
} ;
1274
1274
}
1275
1275
1276
- py_native_func_factory_tuple ! ( ( a, A ) ) ;
1277
- py_native_func_factory_tuple ! ( ( a, A ) , ( b, B ) ) ;
1278
- py_native_func_factory_tuple ! ( ( a, A ) , ( b, B ) , ( c, C ) ) ;
1279
- py_native_func_factory_tuple ! ( ( a, A ) , ( b, B ) , ( c, C ) , ( d, D ) ) ;
1280
- py_native_func_factory_tuple ! ( ( a, A ) , ( b, B ) , ( c, C ) , ( d, D ) , ( e, E ) ) ;
1276
+ into_py_native_func_tuple ! ( ( a, A ) ) ;
1277
+ into_py_native_func_tuple ! ( ( a, A ) , ( b, B ) ) ;
1278
+ into_py_native_func_tuple ! ( ( a, A ) , ( b, B ) , ( c, C ) ) ;
1279
+ into_py_native_func_tuple ! ( ( a, A ) , ( b, B ) , ( c, C ) , ( d, D ) ) ;
1280
+ into_py_native_func_tuple ! ( ( a, A ) , ( b, B ) , ( c, C ) , ( d, D ) , ( e, E ) ) ;
1281
1281
1282
1282
/// Rather than determining the type of a python object, this enum is more
1283
1283
/// a holder for the rust payload of a python object. It is more a carrier
0 commit comments