Skip to content
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

Use IntoIterator instead of Into<Vec<..>> in cubic splines interfaces #16402

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mweatherley
Copy link
Contributor

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.

@mweatherley mweatherley added D-Trivial Nice and easy! A great choice to get started with Bevy A-Math Fundamental domain-agnostic mathematical operations X-Uncontroversial This work is generally agreed upon S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 16, 2024
@mweatherley mweatherley added this to the 0.16 milestone Nov 16, 2024
@mweatherley mweatherley added the C-Usability A targeted quality-of-life change that makes Bevy easier to use label Nov 16, 2024
@mweatherley mweatherley added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Math Fundamental domain-agnostic mathematical operations C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants