Merge pull request #1597 from m-ou-se/wrap-pyfunction-as-closure
Expand wrap_pyfunction!() to a closure to improve deduction.
This commit is contained in:
commit
4edc7c6dc5
|
@ -221,7 +221,7 @@ pub mod proc_macro {
|
|||
#[macro_export]
|
||||
macro_rules! wrap_pyfunction {
|
||||
($function_name: ident) => {{
|
||||
&pyo3::paste::expr! { [<__pyo3_get_function_ $function_name>] }
|
||||
&|py| pyo3::paste::expr! { [<__pyo3_get_function_ $function_name>] }(py)
|
||||
}};
|
||||
|
||||
($function_name: ident, $arg: expr) => {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
use pyo3::{prelude::*, types::PyCFunction, wrap_pyfunction};
|
||||
|
||||
#[pyfunction]
|
||||
fn f() {}
|
||||
|
||||
pub fn add_wrapped(wrapper: &impl Fn(Python) -> PyResult<&PyCFunction>) {
|
||||
let _ = wrapper;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wrap_pyfunction_deduction() {
|
||||
add_wrapped(wrap_pyfunction!(f));
|
||||
}
|
Loading…
Reference in New Issue