pyo3/impl_/pyclass/
assertions.rs#[allow(unused)]
pub const fn assert_pyclass_sync<T>()
where
T: PyClassSync + Sync,
{
}
#[cfg_attr(
diagnostic_namespace,
diagnostic::on_unimplemented(
message = "the trait `Sync` is not implemented for `{Self}`",
label = "required by `#[pyclass]`",
note = "replace thread-unsafe fields with thread-safe alternatives",
note = "see <TODO INSERT PYO3 GUIDE> for more information",
)
)]
pub trait PyClassSync<T: Sync = Self> {}
impl<T> PyClassSync for T where T: Sync {}
mod tests {
#[cfg(feature = "macros")]
#[test]
fn test_assert_pyclass_sync() {
use super::assert_pyclass_sync;
#[crate::pyclass(crate = "crate")]
struct MyClass {}
assert_pyclass_sync::<MyClass>();
}
}