Use IntoIterator instead of Into<Vec<..>> in cubic splines interfaces#16402
Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom Dec 3, 2024
Merged
Conversation
BenjaminBrienen
approved these changes
Nov 17, 2024
mockersf
approved these changes
Nov 17, 2024
IQuick143
approved these changes
Nov 17, 2024
ecoskey
pushed a commit
to ecoskey/bevy
that referenced
this pull request
Jan 6, 2025
…aces (bevyengine#16402) # Objective This was always a bit weird; `IntoIterator` is considered more idiomatic in Rust. The reason these used `Into<Vec<..>>` in the first place was (to my knowledge) because of concerns that passing an already-owned vector would cause a redundant allocation if the iterator API was used instead. However, I have looked at simple examples for this scenario and the generated assembly is identical (i.e. `into_iter().collect()` is effectively converted to a no-op). ## Solution As described in the title. ## Testing It compiles. Ran existing tests. ## Migration Guide The cubic splines API now uses `IntoIterator` in places where it used `Into<Vec<..>>`. For most users, this will have little to no effect (it is largely more permissive). However, in case you were using some unusual input type that implements `Into<Vec<..>>` without implementing `IntoIterator`, you can migrate by converting the input to a `Vec<..>` before passing it into the interface.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
This was always a bit weird;
IntoIteratoris considered more idiomatic in Rust.The reason these used
Into<Vec<..>>in the first place was (to my knowledge) because of concerns that passing an already-owned vector would cause a redundant allocation if the iterator API was used instead. However, I have looked at simple examples for this scenario and the generated assembly is identical (i.e.into_iter().collect()is effectively converted to a no-op).Solution
As described in the title.
Testing
It compiles. Ran existing tests.
Migration Guide
The cubic splines API now uses
IntoIteratorin places where it usedInto<Vec<..>>. For most users, this will have little to no effect (it is largely more permissive). However, in case you were using some unusual input type that implementsInto<Vec<..>>without implementingIntoIterator, you can migrate by converting the input to aVec<..>before passing it into the interface.