pub unsafe trait OffsetCalculator<T: PyClass, U> {
// Required method
fn offset() -> usize;
}
Expand description
Helper trait to locate field within a #[pyclass]
for a #[pyo3(get)]
.
Below MSRV 1.77 we can’t use std::mem::offset_of!
, and the replacement in
memoffset::offset_of
doesn’t work in const contexts for types containing UnsafeCell
.
§Safety
The trait is unsafe to implement because producing an incorrect offset will lead to UB.
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.