Skip to content

Commit 774b0d8

Browse files
authored
Merge pull request RustPython#823 from adrian17/remove-impl
Drop IntoPyNativeFunc impl to fix Nightly/Beta breakages.
2 parents 76659fd + 585e6e5 commit 774b0d8

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

vm/src/function.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,12 +437,6 @@ where
437437
}
438438
}
439439

440-
impl IntoPyNativeFunc<PyFuncArgs, PyResult> for PyNativeFunc {
441-
fn into_func(self) -> PyNativeFunc {
442-
self
443-
}
444-
}
445-
446440
pub struct OwnedParam<T>(std::marker::PhantomData<T>);
447441
pub struct RefParam<T>(std::marker::PhantomData<T>);
448442

wasm/lib/src/vm_class.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -199,32 +199,31 @@ impl WASMVirtualMachine {
199199
fn error() -> JsValue {
200200
TypeError::new("Unknown stdout option, please pass a function or 'console'").into()
201201
}
202-
let print_fn: Box<Fn(&VirtualMachine, PyFuncArgs) -> PyResult> =
203-
if let Some(s) = stdout.as_string() {
204-
match s.as_str() {
205-
"console" => Box::new(wasm_builtins::builtin_print_console),
206-
_ => return Err(error()),
207-
}
208-
} else if stdout.is_function() {
209-
let func = js_sys::Function::from(stdout);
210-
Box::new(move |vm: &VirtualMachine, args: PyFuncArgs| -> PyResult {
202+
let print_fn: PyObjectRef = if let Some(s) = stdout.as_string() {
203+
match s.as_str() {
204+
"console" => vm.ctx.new_rustfunc(wasm_builtins::builtin_print_console),
205+
_ => return Err(error()),
206+
}
207+
} else if stdout.is_function() {
208+
let func = js_sys::Function::from(stdout);
209+
vm.ctx
210+
.new_rustfunc(move |vm: &VirtualMachine, args: PyFuncArgs| -> PyResult {
211211
func.call1(
212212
&JsValue::UNDEFINED,
213213
&wasm_builtins::format_print_args(vm, args)?.into(),
214214
)
215215
.map_err(|err| convert::js_to_py(vm, err))?;
216216
Ok(vm.get_none())
217217
})
218-
} else if stdout.is_undefined() || stdout.is_null() {
219-
fn noop(vm: &VirtualMachine, _args: PyFuncArgs) -> PyResult {
220-
Ok(vm.get_none())
221-
}
222-
Box::new(noop)
223-
} else {
224-
return Err(error());
225-
};
226-
vm.set_attr(&vm.builtins, "print", vm.ctx.new_rustfunc(print_fn))
227-
.unwrap();
218+
} else if stdout.is_undefined() || stdout.is_null() {
219+
fn noop(vm: &VirtualMachine, _args: PyFuncArgs) -> PyResult {
220+
Ok(vm.get_none())
221+
}
222+
vm.ctx.new_rustfunc(noop)
223+
} else {
224+
return Err(error());
225+
};
226+
vm.set_attr(&vm.builtins, "print", print_fn).unwrap();
228227
Ok(())
229228
})?
230229
}

0 commit comments

Comments
 (0)