-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - Remove ExactSizeIterator from QueryCombinationIter #5895
[Merged by Bors] - Remove ExactSizeIterator from QueryCombinationIter #5895
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, LGTM
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed both.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
QueryCombinationIter
can have sizes greater thanusize::MAX
.Solution
ExactSizeIterator
has been removed. Instead of usingquery_combination.len()
, you can usequery_combination.size_hint().0
to get the same value as before.Migration Guide