mirror of
https://github.com/bevyengine/bevy
synced 2024-12-23 03:23:20 +00:00
44e9cd4bfc
# Objective Fixes #5362 ## Solution Add the attribute `#[label(ignore_fields)]` for `*Label` types. ```rust #[derive(SystemLabel)] pub enum MyLabel { One, // Previously this was not allowed since labels cannot contain data. #[system_label(ignore_fields)] Two(PhantomData<usize>), } ``` ## Notes This label makes it possible for equality to behave differently depending on whether or not you are treating the type as a label. For example: ```rust #[derive(SystemLabel, PartialEq, Eq)] #[system_label(ignore_fields)] pub struct Foo(usize); ``` If you compare it as a label, it will ignore the wrapped fields as the user requested. But if you compare it as a `Foo`, the derive will incorrectly compare the inner fields. I see a few solutions 1. Do nothing. This is technically intended behavior, but I think we should do our best to prevent footguns. 2. Generate impls of `PartialEq` and `Eq` along with the `#[derive(Label)]` macros. This is a breaking change as it requires all users to remove these derives from their types. 3. Only allow `PhantomData` to be used with `ignore_fields` -- seems needlessly prescriptive. --- ## Changelog * Added the `ignore_fields` attribute to the derive macros for `*Label` types. * Added an example showing off different forms of the derive macro. <!-- ## Migration Guide > This section is optional. If there are no breaking changes, you can delete this section. - If this PR is a breaking change (relative to the last release of Bevy), describe how a user might need to migrate their code to support these changes - Simply adding new functionality is not a breaking change. - Fixing behavior that was definitely a bug, rather than a questionable design choice is not a breaking change. -->
47 lines
1.1 KiB
TOML
47 lines
1.1 KiB
TOML
[package]
|
|
name = "bevy_ecs"
|
|
version = "0.8.0-dev"
|
|
edition = "2021"
|
|
description = "Bevy Engine's entity component system"
|
|
homepage = "https://bevyengine.org"
|
|
repository = "https://github.com/bevyengine/bevy"
|
|
license = "MIT OR Apache-2.0"
|
|
keywords = ["ecs", "game", "bevy"]
|
|
categories = ["game-engines", "data-structures"]
|
|
|
|
[features]
|
|
trace = []
|
|
default = ["bevy_reflect"]
|
|
|
|
[dependencies]
|
|
bevy_ptr = { path = "../bevy_ptr", version = "0.8.0-dev" }
|
|
bevy_reflect = { path = "../bevy_reflect", version = "0.8.0-dev", optional = true }
|
|
bevy_tasks = { path = "../bevy_tasks", version = "0.8.0-dev" }
|
|
bevy_utils = { path = "../bevy_utils", version = "0.8.0-dev" }
|
|
bevy_ecs_macros = { path = "macros", version = "0.8.0-dev" }
|
|
|
|
async-channel = "1.4"
|
|
thread_local = "1.1.4"
|
|
fixedbitset = "0.4"
|
|
fxhash = "0.2"
|
|
downcast-rs = "1.2"
|
|
serde = "1"
|
|
|
|
[dev-dependencies]
|
|
rand = "0.8"
|
|
|
|
[[example]]
|
|
name = "events"
|
|
path = "examples/events.rs"
|
|
|
|
[[example]]
|
|
name = "resources"
|
|
path = "examples/resources.rs"
|
|
|
|
[[example]]
|
|
name = "change_detection"
|
|
path = "examples/change_detection.rs"
|
|
|
|
[[example]]
|
|
name = "derive_label"
|
|
path = "examples/derive_label.rs"
|