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
33impl<'a, 'py, T: 'a> IsIntoPyObjectRef<T>
34where
35 &'a T: IntoPyObject<'py>,
36{
37 pub const VALUE: bool = true;
38}
39
40probe!(IsIntoPyObject);
41
42impl<'py, T> IsIntoPyObject<T>
43where
44 T: IntoPyObject<'py>,
45{
46 pub const VALUE: bool = true;
47}
48
49probe!(IsSend);
50
51impl<T: Send> IsSend<T> {
52 pub const VALUE: bool = true;
53}
54
55probe!(IsSync);
56
57impl<T: Sync> IsSync<T> {
58 pub const VALUE: bool = true;
59}
60
61probe!(IsOption);
62
63impl<T> IsOption<Option<T>> {
64 pub const VALUE: bool = true;
65}
66
67probe!(HasNewTextSignature);
68
69impl<T: super::doc::PyClassNewTextSignature> HasNewTextSignature<T> {
70 pub const VALUE: bool = true;
71}
72
73#[cfg(test)]
74macro_rules! value_of {
75 ($probe:ident, $ty:ty) => {{
76 #[allow(unused_imports)] use crate::impl_::pyclass::Probe as _;
78 $probe::<$ty>::VALUE
79 }};
80}
81
82#[cfg(test)]
83pub(crate) use value_of;