use std::marker::PhantomData;
use crate::{conversion::IntoPyObject, FromPyObject, Py};
pub trait Probe {
const VALUE: bool = false;
}
macro_rules! probe {
($name:ident) => {
pub struct $name<T>(PhantomData<T>);
impl<T> Probe for $name<T> {}
};
}
probe!(IsPyT);
impl<T> IsPyT<Py<T>> {
pub const VALUE: bool = true;
}
probe!(IsIntoPyObjectRef);
impl<'a, 'py, T: 'a> IsIntoPyObjectRef<T>
where
&'a T: IntoPyObject<'py>,
{
pub const VALUE: bool = true;
}
probe!(IsIntoPyObject);
impl<'py, T> IsIntoPyObject<T>
where
T: IntoPyObject<'py>,
{
pub const VALUE: bool = true;
}
probe!(IsSend);
impl<T: Send> IsSend<T> {
pub const VALUE: bool = true;
}
probe!(IsSync);
impl<T: Sync> IsSync<T> {
pub const VALUE: bool = true;
}
probe!(IsFromPyObject);
impl<'a, 'py, T> IsFromPyObject<T>
where
T: FromPyObject<'a, 'py>,
{
pub const VALUE: bool = true;
}
probe!(HasNewTextSignature);
impl<T: super::doc::PyClassNewTextSignature> HasNewTextSignature<T> {
pub const VALUE: bool = true;
}
#[cfg(test)]
macro_rules! value_of {
($probe:ident, $ty:ty) => {{
#[allow(unused_imports)] use crate::impl_::pyclass::Probe as _;
$probe::<$ty>::VALUE
}};
}
#[cfg(test)]
pub(crate) use value_of;