Skip to content

Commit 7ca38fd

Browse files
authored
Make ObjectId Send + Sync (#500)
1 parent 2efcfb8 commit 7ca38fd

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ Unreleased
2525
which returns a `Result<&'static [ResourceType], StoreObjectConversionError>`
2626
- Add missing `StoreObject::Reactor` to the `seasonal-season-5` feature.
2727

28+
### Other
29+
- Change `PhantomData` in `screeps::local::ObjectId` to better model `ObjectId`'s relationship with the wrapped type.
30+
- This allows `ObjectId` to be `Send + Sync` regardless of the wrapped type
31+
2832
0.20.1 (2024-01-09)
2933
===================
3034

src/local/object_id.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ pub use raw::*;
6060
#[serde(transparent, bound = "")]
6161
pub struct ObjectId<T> {
6262
raw: RawObjectId,
63+
64+
// Needed to consider the `T` as "used" even though we mostly use it as a marker. Because of
65+
// auto traits, `PhantomData<fn() -> T>` is used instead: this struct doesn't *hold* a `T`, it
66+
// *produces* one.
6367
#[serde(skip)]
64-
phantom: PhantomData<T>,
68+
phantom: PhantomData<fn() -> T>,
6569
}
6670

6771
// traits implemented manually so they don't depend on `T` implementing them.

0 commit comments

Comments
 (0)