Closed 3tilley closed 9 months ago
This looks quite nice. But the DeviceCollectionIter should only borrow the DeviceCollection. Now it takes ownership so you won't be able to use the DeviceCollection again after iterating. The borrow needs lifetime annotations, just copy those from alsa-rs.
The name of the iterator struct is not really important since this struct is mostly hidden from library users.
I'll bump the version when I release.
Thanks for your feedback, I really appreciate your guidance - changes made.
Is there a reason alsa-rs
hasn't implemented IntoIterator
apart from just not thinking it was a priority? I'm just interested as to whether there are corner cases where it's a bad idea, or if it's only an ergonomic positive.
Looks good, I'll take it for a spin as soon as I'm on a windows machine.
I think that IntoIter makes sense for things where it's obvious what the iterator will iterate over. It works perfectly for an array for example. It's also a good fit here for the Wasapi DeviceCollection. It will obviously iterate over devices. But an Alsa Ctl has a lot of functionality where nothing is clearly the thing to iterate over.
The example imports and sets up logging, but then id doesn't need it for anything. Can you remove it?
That's a good find! Updated
Is this what you imagined? Any strong feelings on
DeviceCollectionIter
instead ofDeviceIter
?Also would I bump the version in this PR, or is that something you do prior to release?