File: test_wrap_pyfunction_deduction.rs

package info (click to toggle)
rust-pyo3 0.22.6-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,420 kB
  • sloc: makefile: 58; python: 39; sh: 1
file content (29 lines) | stat: -rw-r--r-- 669 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#![cfg(feature = "macros")]

use pyo3::{prelude::*, types::PyCFunction};

#[pyfunction]
fn f() {}

#[cfg(feature = "gil-refs")]
pub fn add_wrapped(wrapper: &impl Fn(Python<'_>) -> PyResult<&PyCFunction>) {
    let _ = wrapper;
}

#[test]
fn wrap_pyfunction_deduction() {
    #[allow(deprecated)]
    #[cfg(feature = "gil-refs")]
    add_wrapped(wrap_pyfunction!(f));
    #[cfg(not(feature = "gil-refs"))]
    add_wrapped_bound(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));
}