cpal icon indicating copy to clipboard operation
cpal copied to clipboard

Add extra devices iterator type alias

Open jacobtread opened this issue 1 year ago • 0 comments

Description

This change adds an additional type alias DevicesFiltered that the InputDevices and OuputDevices can both become aliases to since they are both the same type, rather than having the same type declared separately twice.

This makes it easier for working with the functions in a case where you may be wanting to filter over either input or output devices using the same function like so:

type DevicesFn = fn(&Host) -> Result<DevicesFiltered, DevicesError>;

let devices_fn: DevicesFn = if output {
    Host::output_devices
} else {
    Host::input_devices
};
let devices_iter = devices_fn(host)
    .expect("Failed to load devices");

Changes

  • Add DevicesFiltered type alias shared by both InputDevices and OuputDevices

jacobtread avatar Jan 17 '24 07:01 jacobtread