Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support customized offset #2

Merged
merged 2 commits into from
Nov 11, 2024
Merged

feat: support customized offset #2

merged 2 commits into from
Nov 11, 2024

Conversation

MrCroxx
Copy link

@MrCroxx MrCroxx commented Nov 11, 2024

Support customized offset for indirect wrapper usage:

#[cfg(test)]
mod tests {
    use crate::LinkedListLink;
    use core::cell::UnsafeCell;
    use std::rc::Rc;

    struct Obj {
        link: LinkedListLink,
    }

    struct Wrapper {
        obj: Obj,
    }

    struct IndirectWrapper {
        cell: UnsafeCell<Obj>,
    }

    intrusive_adapter! {
        /// Test doc comment
        ObjAdapter1 = Rc<Obj>: Obj { link => LinkedListLink }
    }

    intrusive_adapter! {
        /// Test doc comment
        WrapperAdapter1 = Rc<Wrapper>: Wrapper { obj.link => LinkedListLink }
    }

    intrusive_adapter! {
        /// Test doc comment
        IndirectWrapperAdapter1 = Rc<Wrapper>: Wrapper { ?offset = crate::offset_of!(IndirectWrapper, cell) + crate::offset_of!(Obj, link) => LinkedListLink }
    }
}

Signed-off-by: MrCroxx [email protected]Signed-off-by: MrCroxx [email protected]

@MrCroxx MrCroxx added the enhancement New feature or request label Nov 11, 2024
@MrCroxx MrCroxx self-assigned this Nov 11, 2024
@MrCroxx MrCroxx merged commit 1357f77 into foyer Nov 11, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant