Defines how a type is tracked within a linked list. In order to support storing a single type within multiple lists, accessing the list pointers is decoupled from the entry type. # Safety Implementations must guarantee that `Target` types are pinned in memory. In other words, when a node is inserted, the value will not be moved as long as it is stored in the list.
| 73 | /// other words, when a node is inserted, the value will not be moved as long as |
| 74 | /// it is stored in the list. |
| 75 | pub unsafe trait Link { |
| 76 | /// Handle to the list entry. |
| 77 | /// |
| 78 | /// This is usually a pointer-ish type. |
| 79 | type Handle; |
| 80 | |
| 81 | /// Node type. |
| 82 | type Target; |
| 83 | |
| 84 | /// Convert the handle to a raw pointer without consuming the handle. |
| 85 | #[allow(clippy::wrong_self_convention)] |
| 86 | fn as_raw(handle: &Self::Handle) -> NonNull<Self::Target>; |
| 87 | |
| 88 | /// Convert the raw pointer to a handle |
| 89 | unsafe fn from_raw(ptr: NonNull<Self::Target>) -> Self::Handle; |
| 90 | |
| 91 | /// Return the pointers for a node |
| 92 | unsafe fn pointers(target: NonNull<Self::Target>) -> NonNull<Pointers<Self::Target>>; |
| 93 | } |
| 94 | |
| 95 | /// Previous / next pointers. |
| 96 | pub struct Pointers<T> { |
no outgoing calls
no test coverage detected