Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy committed Jan 10, 2024
1 parent e0376f0 commit b426f1c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cppgc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ pub struct InnerMember {
ptr: *mut (),
}

impl InnerMember {
pub unsafe fn get<T: GarbageCollected>(&self) -> &T {
unsafe { self.ptr.cast::<T>().as_ref().unwrap() }
}
}

/// Members are used to contain strong pointers to other garbage
/// collected objects. All members fields on garbage collected objects
/// must be trace in the `trace` method.
Expand All @@ -238,7 +244,7 @@ impl<T: GarbageCollected> Member<T> {
///
/// There are no guarantees that the object is alive and not garbage collected.
pub unsafe fn get(&self) -> &T {
unsafe { (*self.handle).ptr.cast::<T>().as_ref().unwrap() }
unsafe { (*self.handle).get() }
}
}

Expand Down

0 comments on commit b426f1c

Please sign in to comment.