Skip to content

Make ObjectId Send + Sync #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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