Skip to content

Commit 8303743

Browse files
committed
Remove RustPyFunc trait, just use Fn(..) everywhere
1 parent 396842e commit 8303743

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

vm/src/pyobject.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ impl PyContext {
452452
)
453453
}
454454

455-
pub fn new_rustfunc<F: 'static + RustPyFunc>(
455+
pub fn new_rustfunc<F: 'static + Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult>(
456456
&self,
457457
function: F,
458458
) -> PyObjectRef {
@@ -466,7 +466,7 @@ impl PyContext {
466466

467467
pub fn new_rustfunc_from_box(
468468
&self,
469-
function: Box<RustPyFunc>,
469+
function: Box<Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult>,
470470
) -> PyObjectRef {
471471
PyObject::new(
472472
PyObjectKind::RustFunction { function },
@@ -478,7 +478,7 @@ impl PyContext {
478478
PyObject::new(PyObjectKind::Frame { frame: frame }, self.frame_type())
479479
}
480480

481-
pub fn new_property<F: 'static + RustPyFunc>(
481+
pub fn new_property<F: 'static + Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult>(
482482
&self,
483483
function: F,
484484
) -> PyObjectRef {
@@ -523,7 +523,7 @@ impl PyContext {
523523
)
524524
}
525525

526-
pub fn new_member_descriptor<F: 'static + RustPyFunc>(
526+
pub fn new_member_descriptor<F: 'static + Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult>(
527527
&self,
528528
function: F,
529529
) -> PyObjectRef {
@@ -783,9 +783,6 @@ impl PyFuncArgs {
783783
}
784784
}
785785

786-
pub trait RustPyFunc: (Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult) {}
787-
impl<T: Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult> RustPyFunc for T {}
788-
789786
/// Rather than determining the type of a python object, this enum is more
790787
/// a holder for the rust payload of a python object. It is more a carrier
791788
/// of rust data for a particular python object. Determine the python type
@@ -862,7 +859,7 @@ pub enum PyObjectKind {
862859
dict: PyObjectRef,
863860
},
864861
RustFunction {
865-
function: Box<RustPyFunc>,
862+
function: Box<Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult>,
866863
},
867864
}
868865

wasm/lib/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn eval_py(source: &str, options: Option<Object>) -> Result<JsValue, JsValue
148148
};
149149
let mut vm = VirtualMachine::new();
150150

151-
let print_fn: Box<pyobject::RustPyFunc> = match stdout {
151+
let print_fn: Box<Fn(&mut VirtualMachine, PyFuncArgs) -> PyResult> = match stdout {
152152
Some(val) => {
153153
if let Some(selector) = val.as_string() {
154154
Box::new(

0 commit comments

Comments
 (0)