Macro impl_list_item

Source
macro_rules! impl_list_item {
    (
        $(impl$({$($generics:tt)*})? ListItem<$num:tt> for $self:ty {
            using ListLinks { self$(.$field:ident)* };
        })*
    ) => { ... };
    (
        $(impl$({$($generics:tt)*})? ListItem<$num:tt> for $self:ty {
            using ListLinksSelfPtr { self$(.$field:ident)* };
        })*
    ) => { ... };
}
Expand description

Implements the ListItem trait for the given type.

Requires that the type implements HasListLinks. Use the impl_has_list_links! macro to implement that trait.

ยงExamples

#[pin_data]
struct SimpleListItem {
    value: u32,
    #[pin]
    links: kernel::list::ListLinks,
}

kernel::list::impl_list_arc_safe! {
    impl ListArcSafe<0> for SimpleListItem { untracked; }
}

kernel::list::impl_list_item! {
    impl ListItem<0> for SimpleListItem { using ListLinks { self.links }; }
}

struct ListLinksHolder {
    inner: kernel::list::ListLinks,
}

#[pin_data]
struct ComplexListItem<T, U> {
    value: Result<T, U>,
    #[pin]
    links: ListLinksHolder,
}

kernel::list::impl_list_arc_safe! {
    impl{T, U} ListArcSafe<0> for ComplexListItem<T, U> { untracked; }
}

kernel::list::impl_list_item! {
    impl{T, U} ListItem<0> for ComplexListItem<T, U> { using ListLinks { self.links.inner }; }
}
#[pin_data]
struct SimpleListItem {
    value: u32,
    #[pin]
    links: kernel::list::ListLinksSelfPtr<SimpleListItem>,
}

kernel::list::impl_list_arc_safe! {
    impl ListArcSafe<0> for SimpleListItem { untracked; }
}

kernel::list::impl_list_item! {
    impl ListItem<0> for SimpleListItem { using ListLinksSelfPtr { self.links }; }
}

struct ListLinksSelfPtrHolder<T, U> {
    inner: kernel::list::ListLinksSelfPtr<ComplexListItem<T, U>>,
}

#[pin_data]
struct ComplexListItem<T, U> {
    value: Result<T, U>,
    #[pin]
    links: ListLinksSelfPtrHolder<T, U>,
}

kernel::list::impl_list_arc_safe! {
    impl{T, U} ListArcSafe<0> for ComplexListItem<T, U> { untracked; }
}

kernel::list::impl_list_item! {
    impl{T, U} ListItem<0> for ComplexListItem<T, U> {
        using ListLinksSelfPtr { self.links.inner };
    }
}