Skip to content

Commit a70f251

Browse files
PyNativeFuncFactory => IntoPyNativeFunc
1 parent e2e3353 commit a70f251

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

vm/src/pyobject.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -576,13 +576,13 @@ impl PyContext {
576576
)
577577
}
578578

579-
pub fn new_rustfunc<F, T, R>(&self, factory: F) -> PyObjectRef
579+
pub fn new_rustfunc<F, T, R>(&self, f: F) -> PyObjectRef
580580
where
581-
F: PyNativeFuncFactory<T, R>,
581+
F: IntoPyNativeFunc<T, R>,
582582
{
583583
PyObject::new(
584584
PyObjectPayload::RustFunction {
585-
function: factory.create(),
585+
function: f.into_func(),
586586
},
587587
self.builtin_function_or_method_type(),
588588
)
@@ -1234,35 +1234,35 @@ tuple_from_py_func_args!(A, B, C, D, E);
12341234

12351235
pub type PyNativeFunc = Box<dyn Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult + 'static>;
12361236

1237-
pub trait PyNativeFuncFactory<T, R> {
1238-
fn create(self) -> PyNativeFunc;
1237+
pub trait IntoPyNativeFunc<T, R> {
1238+
fn into_func(self) -> PyNativeFunc;
12391239
}
12401240

1241-
impl<F> PyNativeFuncFactory<PyFuncArgs, PyResult> for F
1241+
impl<F> IntoPyNativeFunc<PyFuncArgs, PyResult> for F
12421242
where
12431243
F: Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult + 'static,
12441244
{
1245-
fn create(self) -> PyNativeFunc {
1245+
fn into_func(self) -> PyNativeFunc {
12461246
Box::new(self)
12471247
}
12481248
}
12491249

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 {
12521252
self
12531253
}
12541254
}
12551255

1256-
macro_rules! py_native_func_factory_tuple {
1256+
macro_rules! into_py_native_func_tuple {
12571257
($(($n:tt, $T:ident)),+) => {
1258-
impl<F, $($T,)+ R> PyNativeFuncFactory<($($T,)+), R> for F
1258+
impl<F, $($T,)+ R> IntoPyNativeFunc<($($T,)+), R> for F
12591259
where
12601260
F: Fn($($T,)+ &mut VirtualMachine) -> R + 'static,
12611261
$($T: FromArgs,)+
12621262
($($T,)+): FromArgs,
12631263
R: IntoPyObject,
12641264
{
1265-
fn create(self) -> PyNativeFunc {
1265+
fn into_func(self) -> PyNativeFunc {
12661266
Box::new(move |vm, args| {
12671267
let ($($n,)+) = args.bind::<($($T,)+)>(vm)?;
12681268

@@ -1273,11 +1273,11 @@ macro_rules! py_native_func_factory_tuple {
12731273
};
12741274
}
12751275

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));
12811281

12821282
/// Rather than determining the type of a python object, this enum is more
12831283
/// a holder for the rust payload of a python object. It is more a carrier

0 commit comments

Comments
 (0)