-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ExactSizeIterator implementation for QueryCombinatonIter (#5148)
Following #5124 I decided to add the `ExactSizeIterator` impl for `QueryCombinationIter`. Also: - Clean up the tests for `size_hint` and `len` for both the normal `QueryIter` and `QueryCombinationIter`. - Add tests to `QueryCombinationIter` when it shouldn't be `ExactSizeIterator` --- ## Changelog - Added `ExactSizeIterator` implementation for `QueryCombinatonIter`
- Loading branch information
Showing
4 changed files
with
184 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
crates/bevy_ecs_compile_fail_tests/tests/ui/query_combin_exact_sized_iterator_safety.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use bevy_ecs::prelude::*; | ||
|
||
#[derive(Component)] | ||
struct Foo; | ||
#[derive(Component)] | ||
struct Bar; | ||
|
||
fn on_changed(query: Query<&Foo, Or<(Changed<Foo>, With<Bar>)>>) { | ||
// this should fail to compile | ||
is_exact_size_iterator(query.iter_combinations::<2>()); | ||
} | ||
|
||
fn on_added(query: Query<&Foo, (Added<Foo>, Without<Bar>)>) { | ||
// this should fail to compile | ||
is_exact_size_iterator(query.iter_combinations::<2>()); | ||
} | ||
|
||
fn is_exact_size_iterator<T: ExactSizeIterator>(_iter: T) {} | ||
|
||
fn main() {} |
Oops, something went wrong.