Skip to content

Commit

Permalink
test: add indirect wrapper example
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx committed Nov 11, 2024
1 parent 7ea0b3b commit fecd493
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ macro_rules! intrusive_adapter {
#[cfg(test)]
mod tests {
use crate::LinkedListLink;
use core::cell::UnsafeCell;
use std::rc::Rc;

struct Obj {
Expand All @@ -287,6 +288,10 @@ mod tests {
obj: Obj,
}

struct IndirectWrapper {
cell: UnsafeCell<Obj>,
}

intrusive_adapter! {
/// Test doc comment
ObjAdapter1 = Rc<Obj>: Obj { link => LinkedListLink }
Expand All @@ -299,6 +304,6 @@ mod tests {

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

0 comments on commit fecd493

Please sign in to comment.