a3ad28b70c
* Support Bound in pymodule and pyfunction macros Co-authored-by: David Hewitt <mail@davidhewitt.dev> * Remove spurious $ character Co-authored-by: Matthew Neeley <mneeley@gmail.com> * Rework PyCFunction::new_bound signatures This allows us to remove the awkward `PyFunctionArgumentsBound` enum. * Use BoundRef instead of BoundModule * support argument deduction for `wrap_pyfunction_bound!` * support `wrap_pyfunction!` with `Bound` input/output * Fix docs link to `wrap_pyfunction_bound!` * Revert back to wrap_pyfunction! --------- Co-authored-by: David Hewitt <mail@davidhewitt.dev> Co-authored-by: Matthew Neeley <mneeley@gmail.com>
25 lines
500 B
Rust
25 lines
500 B
Rust
#![cfg(feature = "macros")]
|
|
|
|
use pyo3::{prelude::*, types::PyCFunction};
|
|
|
|
#[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));
|
|
}
|
|
|
|
pub fn add_wrapped_bound(wrapper: &impl Fn(Python<'_>) -> PyResult<Bound<'_, PyCFunction>>) {
|
|
let _ = wrapper;
|
|
}
|
|
|
|
#[test]
|
|
fn wrap_pyfunction_deduction_bound() {
|
|
add_wrapped_bound(wrap_pyfunction_bound!(f));
|
|
}
|