Unnecessary error in #[system] validation
- Lingua principale
- Rust
- Stelle
- 1.7k
- Fork
- 140
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Was playing with legion (3.1.0) and trying to copy various examples of systems, but kept running into the "simple systems cannot contain component references" error.
https://github.com/amethyst/legion/blob/139a2ad953f119a470934abafdb50ee9c43beb00/codegen/src/lib.rs#L551
I eventually realized that I needed to import the SubWorld rather than qualifying it. I was writing this:
```rust
#[system]
#[read_component(usize)]
#[write_component(bool)]
fn run_query(world: &mut world::SubWorld) {
let mut query = <(&usize, &mut bool)>::query();
for (a, b) in query.iter_mut(world) {
println!("{} {}", a, b);
}
}
```
which is an example from the docs with the `world::` added before SubWorld, and then I got the error above. Pretty new to rust so I expected this to be equivalent to importing and then using it.
Importing it is a fine workaround for me but I thought I'd mention it case it helps someone! Thanks!
Edit: looked a bit more at the code and maybe it's just a matter of adding the "world::SubWorld" case here? I was importing legion as `use legion::*` as it says in the docs in a few places, which made my editor automatically suggest the qualification relative to "world" rather than "legion", I guess. Either that or expose SubWorld from legion::* I guess (didn't seem like it was).
https://github.com/amethyst/legion/blob/139a2ad953f119a470934abafdb50ee9c43beb00/codegen/src/lib.rs#L359
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.