[Merged by Bors] - Remove ExactSizeIterator from QueryCombinationIter#5895
[Merged by Bors] - Remove ExactSizeIterator from QueryCombinationIter#5895ottah wants to merge 2 commits intobevyengine:mainfrom ottah:5846-QueryCominationIter-remove-ExactSizeIterator
Conversation
| for query: {query_type} | ||
| expected: {expected_size} | ||
| len(): {len} | ||
| size_hint().0: {size_hint_0} | ||
| size_hint().1: {size_hint_1:?} | ||
| count(): {count}"# |
There was a problem hiding this comment.
The test doesn't only check for len being consistent, but also size_hint being equivalent to count. Removing the ExactSize impl doesn't imply the size_hint cannot be accurate.
Note that this test both checks both the QueryIter and QueryCombinationIter counts. I suggest extracting the assert_combination, assert_all_sizes_equal, assert_all_sizes_iterator_equal functions, split this test in two, and not test len for QueryCombinationIter.
Also if you are running tests, I recommend you use cargo test --package bevy_ecs query_filtered_exactsizeiterator_len (or whatever new name you come up with) this will save you time.
There was a problem hiding this comment.
I think I've implemented what you suggested by splitting to 2 tests. Is query_filtered_exactsizeiterator_len correct?
|
I'd suggest you edit the PR comment to improve the migration guide. Ideally it contains actionable instructions. Here is an example:
|
crates/bevy_ecs/src/query/mod.rs
Outdated
| r#"query declared sizes: | ||
| for query: {query_type} | ||
| expected: {expected_size} | ||
| len: {len} | ||
| size_hint().0: {size_hint_0} | ||
| size_hint().1: {size_hint_1:?} | ||
| count(): {count}"# |
There was a problem hiding this comment.
| r#"query declared sizes: | |
| for query: {query_type} | |
| expected: {expected_size} | |
| len: {len} | |
| size_hint().0: {size_hint_0} | |
| size_hint().1: {size_hint_1:?} | |
| count(): {count}"# | |
| "query declared sizes: \ | |
| for query: {query_type} \ | |
| expected: {expected_size} \ | |
| len: {len} \ | |
| size_hint().0: {size_hint_0} \ | |
| size_hint().1: {size_hint_1:?} \ | |
| count(): {count}" |
Nit, non blocking, but formatting can be improved
crates/bevy_ecs/src/query/mod.rs
Outdated
| r#"query declared sizes: | ||
| for query: {query_type} | ||
| for query: {query_type} | ||
| expected: {expected_size} | ||
| len(): {len} | ||
| size_hint().0: {size_hint_0} | ||
| size_hint().1: {size_hint_1:?} | ||
| count(): {count}"# |
There was a problem hiding this comment.
Nit: same as previous
"query declared sizes: \
for query: {query_type} \
expected: {expected_size} \
size_hint().0: {size_hint_0} \
size_hint().1: {size_hint_1:?} \
count(): {count}"|
@nicopap Hey I updated the PR due to fix conflicts from |
|
Oh no, more merge conflicts. I'll merge it ASAP once those are resolved. |
QueryCombinationIter can have sizes greater than usize::MAX. - Remove implementation of ExactSizeIterator - Remove UI compile fail tests for ExactSizeIterator - Align println! strings Fixes #5846
WorldQuery -> ReadOnlyWorldQuery world.spawn().insert_bundle(...) -> world.spawn(...)
|
bors r+ |
# Objective - `QueryCombinationIter` can have sizes greater than `usize::MAX`. - Fixes #5846 ## Solution - Only the implementation of `ExactSizeIterator` has been removed. Instead of using `query_combination.len()`, you can use `query_combination.size_hint().0` to get the same value as before. --- ## Migration Guide - Switch to using other methods of getting the length.
|
Pull request successfully merged into main. Build succeeded:
|
# Objective - `QueryCombinationIter` can have sizes greater than `usize::MAX`. - Fixes bevyengine#5846 ## Solution - Only the implementation of `ExactSizeIterator` has been removed. Instead of using `query_combination.len()`, you can use `query_combination.size_hint().0` to get the same value as before. --- ## Migration Guide - Switch to using other methods of getting the length.
# Objective - `QueryCombinationIter` can have sizes greater than `usize::MAX`. - Fixes bevyengine#5846 ## Solution - Only the implementation of `ExactSizeIterator` has been removed. Instead of using `query_combination.len()`, you can use `query_combination.size_hint().0` to get the same value as before. --- ## Migration Guide - Switch to using other methods of getting the length.
# Objective - `QueryCombinationIter` can have sizes greater than `usize::MAX`. - Fixes bevyengine#5846 ## Solution - Only the implementation of `ExactSizeIterator` has been removed. Instead of using `query_combination.len()`, you can use `query_combination.size_hint().0` to get the same value as before. --- ## Migration Guide - Switch to using other methods of getting the length.
Objective
QueryCombinationItercan have sizes greater thanusize::MAX.Solution
ExactSizeIteratorhas been removed. Instead of usingquery_combination.len(), you can usequery_combination.size_hint().0to get the same value as before.Migration Guide