-
Notifications
You must be signed in to change notification settings - Fork 214
Open
Labels
Description
Description
Add a feature auto-component (or maybe specialization) that uses the nightly feature specialization to make everything a component. I noticed there already is a nightly feature, but I wanted to keep them separate for this example.
#![cfg_attr(feature = "auto-component", feature(specialization))]
pub trait Component: Any + Sized {
/// Associated storage type for this component.
type Storage: UnprotectedStorage<Self> + Any + Send + Sync;
}
#[cfg(feature = "auto-component")]
default impl<T> Component for T {
type Storage = BTreeStorage<Self>;
}Motivation
Often I find myself writing annoying wrappers for structs/enums in other crates. Then afterwards it
takes additional steps to get to the data I care about. This is not a perfect solution, but it does help with quick tests, and small projects where memory efficiency and performance can be overlooked for ease of use.
Drawbacks
- This feature requires nightly to work.
- It encourages not explicitly implementing
Componentfor new components.
If this is something that other people want, I can write a quick pull request for it.