From 4563e3da3974d199b099c32e2ef16d77f5887f00 Mon Sep 17 00:00:00 2001 From: Jonathan Spira Date: Sun, 16 Aug 2026 20:58:26 -0400 Subject: [PATCH] feat: make Component opt in --- Cargo.toml | 4 +++- src/world.rs | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 91802e32..a5157228 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ rustdoc-args = ["--cfg", "docsrs"] maintenance = { status = "actively-developed" } [features] -default = ["std"] +default = ["std", "blanket-component"] std = [] # Enables derive(Bundle) and derive(Query) macros = ["hecs-macros"] @@ -27,6 +27,8 @@ macros = ["hecs-macros"] column-serialize = ["serde"] # Enables the serialize::row module row-serialize = ["serde"] +# enables all T to implement Component +blanket-component = [] [dependencies] hecs-macros = { path = "macros", version = "0.11.1", optional = true } diff --git a/src/world.rs b/src/world.rs index b77006fe..be39a625 100644 --- a/src/world.rs +++ b/src/world.rs @@ -1047,11 +1047,13 @@ impl From for QueryOneError { } } -/// Types that can be components, implemented automatically for all `Send + Sync + 'static` types +/// Types that can be components. /// -/// This is just a convenient shorthand for `Send + Sync + 'static`, and never needs to be -/// implemented manually. +/// With the default features enabled, Component is implemented for all `Send + Sync + 'static` types. +/// Otherwise, users must implement component for each type on their own. pub trait Component: Send + Sync + 'static {} + +#[cfg(feature = "blanket-component")] impl Component for T {} /// Iterator over all of a world's entities