pub unsafe trait PointerLength {
// Required method
fn len(ptr: *const Self) -> usize;
}
Expand description
A trait which is only implemented for pointers for which the length of the pointee can be determined without creating a reference to the pointee and without accessing the pointee. This means that the pointer is not dereferenced.
§Example
use deferred_reference::PointerLength;
let array = [0usize; 1024];
assert_eq!(1024, PointerLength::len(core::ptr::addr_of!(array)));
§Safety
This trait is unsafe. The implementor must promise never to access or create a reference to the pointee.
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.