Skip to content

Commit

Permalink
Make ObjectId Send + Sync (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbot95 authored Mar 1, 2024
1 parent 2efcfb8 commit 7ca38fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Unreleased
which returns a `Result<&'static [ResourceType], StoreObjectConversionError>`
- Add missing `StoreObject::Reactor` to the `seasonal-season-5` feature.

### Other
- Change `PhantomData` in `screeps::local::ObjectId` to better model `ObjectId`'s relationship with the wrapped type.
- This allows `ObjectId` to be `Send + Sync` regardless of the wrapped type

0.20.1 (2024-01-09)
===================

Expand Down
6 changes: 5 additions & 1 deletion src/local/object_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ pub use raw::*;
#[serde(transparent, bound = "")]
pub struct ObjectId<T> {
raw: RawObjectId,

// Needed to consider the `T` as "used" even though we mostly use it as a marker. Because of
// auto traits, `PhantomData<fn() -> T>` is used instead: this struct doesn't *hold* a `T`, it
// *produces* one.
#[serde(skip)]
phantom: PhantomData<T>,
phantom: PhantomData<fn() -> T>,
}

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

0 comments on commit 7ca38fd

Please sign in to comment.