Skip to main content

DoublyLinkedListContainable

Derive Macro DoublyLinkedListContainable 

Source
#[derive(DoublyLinkedListContainable)]
{
    // Attributes available to this derive:
    #[dll_node]
}
Expand description

Derive macro to implement DoublyLinkedListContainable for a struct.

Mark fields that are nodes with #[dll_node]. To support multiple lists, use #[dll_node(tag = MyTag)].

DoublyLinkedListNode is !Unpin so that linked elements cannot be moved. On #[pin_data] structs, #[dll_node] fields must also be annotated with #[pin]; otherwise the Unpin impl generated by #[pin_data] ignores the node and the struct becomes Unpin. This derive enforces that requirement at compile time. Place this derive above #[pin_data] so the dll_node helper attribute is in scope (and so this derive can see #[pin_data]):

ⓘ
#[derive(fbl::DoublyLinkedListContainable)]
#[pin_data]
struct Foo {
    #[pin]
    #[dll_node]
    node: fbl::DoublyLinkedListNode<Foo>,
}