amethyst / amethyst/specs

Default Component Impl

オープン
#640 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
feature-request
主要言語
Rust
スター
2.6k
フォーク
215
PR マージ指標
30日以内にマージされた PR はありません

説明

## 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.
```rust
#![cfg_attr(feature = "auto-component", feature(specialization))]

pub trait Component: Any + Sized {
/// Associated storage type for this component.
type Storage: UnprotectedStorage + Any + Send + Sync;
}

#[cfg(feature = "auto-component")]
default impl Component for T {
type Storage = BTreeStorage;
}
```

## 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 `Component` for new components.

If this is something that other people want, I can write a quick pull request for it.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。