Skip to content

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

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
mweatherley:iterators-in-cubic-splines
Dec 3, 2024
Merged

Use IntoIterator instead of Into<Vec<..>> in cubic splines interfaces#16402
alice-i-cecile merged 1 commit intobevyengine:mainfrom
mweatherley:iterators-in-cubic-splines

Conversation

@mweatherley
Copy link
Copy Markdown
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
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 3, 2024
Merged via the queue into bevyengine:main with commit 9d142a8 Dec 3, 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.
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.

5 participants