A Rust port of the C macro container_of.
This macro is used to convert from a pointer to a struct's field to a pointer to the struct itself. Note that the struct should be sized.
Example
#
Safety
The following are needed to ensure soundness:
- The
$typemust be a sized struct that is#[repr(C)](or#[repr(packed)]). - The
$ptrmust be a valid pointer to the$fieldfield of a$type. More concretely, this means that the$ptrmust have originated from a valid$typestruct.