gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.35k stars 548 forks source link

Be explicit about Iterator in the API #3615

Closed kvark closed 3 years ago

kvark commented 3 years ago

Doesn't fix anything, but makes our API a little bit more explicit.

Original motivation for IntoIterator was driven by general Rust best practices, including the idea that users would already pass containers to us, such as Vec, or Option. However, at this point I believe the minor convenience is not worth the additional type layer of IntoIterator. In most cases we don't expect actual containers, we expect users to store the data in their own containers, and then iterator to extract it and provide to us. Overall, in gfx-hal we are trying to be explicit about the costs, and seeing an iterator on the call side helps this a bit.

Finally, as an interesting fact, in most cases in Warden the fix was to just... remove collect(). Generally, we don't want to build an API that promotes passing Vec around. We should discourage this instead.

kvark commented 3 years ago

Let's just proceed. The main consumers don't care that much, and simplification is worth it. bors r+

bors[bot] commented 3 years ago

Build succeeded: