Skip to content

Make EntityHashMap::new and EntityHashSet::new const#17615

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
Jondolf:const-entity-hash-map-and-set
Jan 30, 2025
Merged

Make EntityHashMap::new and EntityHashSet::new const#17615
alice-i-cecile merged 1 commit intobevyengine:mainfrom
Jondolf:const-entity-hash-map-and-set

Conversation

@Jondolf
Copy link
Copy Markdown
Contributor

@Jondolf Jondolf commented Jan 30, 2025

Objective

#16912 turned EntityHashMap and EntityHashSet into proper newtypes instead of type aliases. However, this removed the ability to create these collections in const contexts; previously, you could use EntityHashSet::with_hasher(EntityHash), but it doesn't exist anymore.

Solution

Make EntityHashMap::new and EntityHashSet::new const methods.

@Jondolf Jondolf changed the title Make EntityHashMap::new and EntityHashSey::new const Make EntityHashMap::new and EntityHashSet::new const Jan 30, 2025
@Jondolf Jondolf added D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Uncontroversial This work is generally agreed upon S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 30, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 30, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 30, 2025
Merged via the queue into bevyengine:main with commit 59697f9 Jan 30, 2025
@Jondolf Jondolf deleted the const-entity-hash-map-and-set branch January 30, 2025 22:35
github-merge-queue bot pushed a commit that referenced this pull request Feb 2, 2025
# Objective

Follow-up to #17615.

Bevy's entity collection types like `EntityHashSet` no longer implement
serde's `Serialize` and `Deserialize` after becoming newtypes instead of
type aliases in #16912. This broke some types that support serde for me
in Avian.

I also missed creating const constructors for `EntityIndexMap` and
`EntityIndexSet` in #17615. Oops!

## Solution

Implement `Serialize` and `Deserialize` for Bevy's entity collection
types, and add const constructors for `EntityIndexMap` and
`EntityIndexSet`.

I didn't implement `ReflectSerialize` or `ReflectDeserialize` here,
because I had some trouble fixing the resulting errors, and they were
not implemented previously either.
mrchantey pushed a commit to mrchantey/bevy that referenced this pull request Feb 4, 2025
…17615)

# Objective

bevyengine#16912 turned `EntityHashMap` and `EntityHashSet` into proper newtypes
instead of type aliases. However, this removed the ability to create
these collections in const contexts; previously, you could use
`EntityHashSet::with_hasher(EntityHash)`, but it doesn't exist anymore.

## Solution

Make `EntityHashMap::new` and `EntityHashSet::new` const methods.
mrchantey pushed a commit to mrchantey/bevy that referenced this pull request Feb 4, 2025
…e#17620)

# Objective

Follow-up to bevyengine#17615.

Bevy's entity collection types like `EntityHashSet` no longer implement
serde's `Serialize` and `Deserialize` after becoming newtypes instead of
type aliases in bevyengine#16912. This broke some types that support serde for me
in Avian.

I also missed creating const constructors for `EntityIndexMap` and
`EntityIndexSet` in bevyengine#17615. Oops!

## Solution

Implement `Serialize` and `Deserialize` for Bevy's entity collection
types, and add const constructors for `EntityIndexMap` and
`EntityIndexSet`.

I didn't implement `ReflectSerialize` or `ReflectDeserialize` here,
because I had some trouble fixing the resulting errors, and they were
not implemented previously either.
holmes-software pushed a commit to holmes-software/bevy that referenced this pull request Feb 5, 2025
…17615)

# Objective

bevyengine#16912 turned `EntityHashMap` and `EntityHashSet` into proper newtypes
instead of type aliases. However, this removed the ability to create
these collections in const contexts; previously, you could use
`EntityHashSet::with_hasher(EntityHash)`, but it doesn't exist anymore.

## Solution

Make `EntityHashMap::new` and `EntityHashSet::new` const methods.
holmes-software pushed a commit to holmes-software/bevy that referenced this pull request Feb 5, 2025
…e#17620)

# Objective

Follow-up to bevyengine#17615.

Bevy's entity collection types like `EntityHashSet` no longer implement
serde's `Serialize` and `Deserialize` after becoming newtypes instead of
type aliases in bevyengine#16912. This broke some types that support serde for me
in Avian.

I also missed creating const constructors for `EntityIndexMap` and
`EntityIndexSet` in bevyengine#17615. Oops!

## Solution

Implement `Serialize` and `Deserialize` for Bevy's entity collection
types, and add const constructors for `EntityIndexMap` and
`EntityIndexSet`.

I didn't implement `ReflectSerialize` or `ReflectDeserialize` here,
because I had some trouble fixing the resulting errors, and they were
not implemented previously either.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants