mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
# Objective Citing @mweatherley > As mentioned before, a multi-sampling function in the API which takes an iterator is probably something we want (e.g. `sample_iter(iter: impl IntoIterator<Item = f32>) -> impl IntoIterator<Item = T> { //... }`, but there are some design choices to be made on the details (e.g. does this filter out points that aren't in the domain? does it do sorting? etc.) ## Solution I think the most flexible solution for end users is to expose all the `sample_...` functions with an `iter` equivalent, so we'll have - `sample_iter` - `sample_iter_unchecked` - `sample_iter_clamped` Answering some questions from the original idea: > does this filter out points that aren't in the domain? With the methods the user has the choice to just sample or if they want to filter out invalid types us `sample_iter` and then apply `filter_map` to the iterator returned themselves. > does it do sorting? I think it's the same thing. If the user wants it, they need to do it themselves by either collecting and sorting a `Vec` or using `itertools`. I think there is a legit use case for "please sample me this collection of points that are unordered" and we would destroy it if we take away to much agency from users by sorting for them ## Testing - Added a test which covers all three methods |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
clippy.toml | ||
README.md |