浏览代码

make GenerationalBoxId send and sync

Evan Almloff 1 年之前
父节点
当前提交
4e19f8f2be
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      packages/generational-box/src/lib.rs

+ 4 - 0
packages/generational-box/src/lib.rs

@@ -150,6 +150,10 @@ pub struct GenerationalBoxId {
     generation: u32,
 }
 
+// Safety: GenerationalBoxId is Send and Sync because there is no way to access the pointer.
+unsafe impl Send for GenerationalBoxId {}
+unsafe impl Sync for GenerationalBoxId {}
+
 impl Debug for GenerationalBoxId {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         #[cfg(any(debug_assertions, feature = "check_generation"))]