Macro intrusive_collections::container_of [−][src]
macro_rules! container_of { ($ptr : expr, $container : path, $field : ident) => { ... }; }
Expand description
Unsafe macro to get a raw pointer to an outer object from a pointer to one of its fields.
Examples
use intrusive_collections::container_of; struct S { x: u32, y: u32 }; let container = S { x: 1, y: 2 }; let field = &container.x; let container2: *const S = unsafe { container_of!(field, S, x) }; assert_eq!(&container as *const S, container2);
Safety
This is unsafe because it assumes that the given expression is a valid pointer to the specified field of some container type.