legion icon indicating copy to clipboard operation
legion copied to clipboard

Accept IntoView for various functions

Open Rua opened this issue 5 years ago • 2 comments

Not all functions accept the new syntax using plain &/&mut for component borrows in views. It would be convenient and more consistent if they did. I can find the following:

  • EntityStore::get_component_storage
  • (Sub)World::split

The syntax might also be considered for fetching resources, to be consistent with components.

Rua avatar Aug 12 '20 10:08 Rua

Oh, wow... So I was having a fiddle with this and I realised that there is no reason why I couldn't change Query itself to require IntoView rather than for<'a> View<'a>, nor why I couldnt give the filter type parameter a default value...

So it seems now you can actually write query types as Query<(&Velocity, &mut Position)>, and if you want you can construct them with Query::<(&Velocity, &mut Position)>::new(). Things get more complex if you add additional filters to the query, but for basic queries this works well.

TomGillen avatar Aug 12 '20 21:08 TomGillen

Thanks, that works nicely. What about using this syntax for fetching resources, is that feasible?

Rua avatar Aug 13 '20 07:08 Rua