pyo3/impl_/pyclass/
probes.rs1use std::marker::PhantomData;
2
3use crate::{conversion::IntoPyObject, Py};
4
5pub trait Probe {
15 const VALUE: bool = false;
16}
17
18macro_rules! probe {
19 ($name:ident) => {
20 pub struct $name<T>(PhantomData<T>);
21 impl<T> Probe for $name<T> {}
22 };
23}
24
25probe!(IsPyT);
26
27impl<T> IsPyT<Py<T>> {
28 pub const VALUE: bool = true;
29}
30
31probe!(IsIntoPyObjectRef);
32
33#[allow(clippy::extra_unused_lifetimes)]
36impl<'a, 'py, T: 'a> IsIntoPyObjectRef<T>
37where
38 &'a T: IntoPyObject<'py>,
39{
40 pub const VALUE: bool = true;
41}
42
43probe!(IsIntoPyObject);
44
45impl<'py, T> IsIntoPyObject<T>
46where
47 T: IntoPyObject<'py>,
48{
49 pub const VALUE: bool = true;
50}
51
52probe!(IsSync);
53
54impl<T: Sync> IsSync<T> {
55 pub const VALUE: bool = true;
56}
57
58probe!(IsOption);
59
60impl<T> IsOption<Option<T>> {
61 pub const VALUE: bool = true;
62}