Skip to content

Conversation

@MrCroxx
Copy link
Member

@MrCroxx MrCroxx commented Nov 9, 2024

As the nested field access feature with offset_of is supported since Rust stable 1.82.0, it is time to support nested field access with intrusive_adapter! macro too!

Changes:

  1. Support nested field access with macro intrusive_adapter! and container_of.
  2. Replace : with => to identify the link for the intrusive data structure. To support nested field access with offset_of, it requires the path to the link to be identified by $($fields:expr)+. Only =>, ,, ; can be used with the tailing expr. And => suits the scenario here.

Example: (copied from the test)

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

    struct Obj {
        link: LinkedListLink,
    }

    struct Wrapper {
        obj: Obj,
    }

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

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

Requirements:

  1. Bump MSRV to 1.82.0 .
  2. Bump the major version of intrusive-collections.

FYI:

  1. Rust 1.82.0 release log: https://releases.rs/docs/1.82.0/#language
  2. offset_of_nested stabilization PR: Stabilize offset_of_nested rust-lang/rust#128284

Signed-off-by: MrCroxx <mrcroxx@outlook.com>
@MrCroxx MrCroxx added the enhancement New feature or request label Nov 9, 2024
@MrCroxx MrCroxx self-assigned this Nov 9, 2024
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
@MrCroxx MrCroxx merged commit 0fa76e1 into foyer Nov 9, 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.

2 participants