bevy/release-content/migration-guides/combine_query_and_query_lens.md
2025-06-23 11:08:40 -04:00

629 B

title pull_requests
Combine `Query` and `QueryLens`
18162

The QueryLens::query() method has been deprecated. The QueryLens type has now been combined with Query, so most methods can be called directly on the QueryLens and the call can simply be removed. If that doesn't work and you do need a fresh Query, the call to .query() can be replaced with .reborrow().

fn with_query(query: Query<&T>) {}
fn with_lens(lens: QueryLens<&T>) -> Result {
  // 0.16
  for item in lens.query().iter() {}
  with_query(lens.query());
  // 0.17
  for item in lens.iter() {}
  with_query(lens.reborrow());
}