amethyst / amethyst/rustrogueliketutorial

Chapter 45: Lifetimes and Assigning Renderable components

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

説明

While going along with the tutorial, it was mentioned that you couldn't resolve the lifetime issues at the time. I am just dropping this off as a solution with lifetimes. My Renderer component differs slightly from the tutorial one, so I have adapted my code to it for this.

I believe the reason that the lifetimes are necessary, is because `EntityBuilder::with()` returns `Self`. This means that the passed `EntityBuilder` must live at least as long as `assign_render` is running, and since we build upon the passed builder, the one that we return must also live as long as the passed `EntityBuilder`, hence the connection between the three.

```Rust
fn assign_render<'a>(new_entity: EntityBuilder<'a>, render: &RawRender) -> EntityBuilder<'a> {
new_entity.with(Renderable {
glyph: render.glyph,
fg: render.fg,
bg: render.bg,
colors,
})
}
```

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

このリポジトリのコントリビューションガイドは索引されていません

評価

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

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

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