mirror of
https://github.com/arabianq/pipewire-soundpad.git
synced 2026-04-28 06:21:23 +00:00
refactor: replace contains_key/unwrap with if let Some in pipewire.rs (#39)
This commit replaces two instances of `contains_key` followed by `get_mut().unwrap()` with the more idiomatic `if let Some(...)` pattern in `src/utils/pipewire.rs`. This reduces redundant hash map lookups and eliminates potential panics from `unwrap()`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
02306b5893
commit
b8baeb6226
@@ -153,8 +153,7 @@ pub async fn get_all_devices() -> Result<(Vec<AudioDevice>, Vec<AudioDevice>), B
|
||||
for port in ports {
|
||||
let node_id = port.node_id;
|
||||
|
||||
if input_devices.contains_key(&node_id) {
|
||||
let input_device = input_devices.get_mut(&node_id).unwrap();
|
||||
if let Some(input_device) = input_devices.get_mut(&node_id) {
|
||||
match port.name.as_str() {
|
||||
"input_FL" => input_device.input_fl = Some(port),
|
||||
"input_FR" => input_device.input_fr = Some(port),
|
||||
@@ -172,8 +171,7 @@ pub async fn get_all_devices() -> Result<(Vec<AudioDevice>, Vec<AudioDevice>), B
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else if output_devices.contains_key(&node_id) {
|
||||
let output_device = output_devices.get_mut(&node_id).unwrap();
|
||||
} else if let Some(output_device) = output_devices.get_mut(&node_id) {
|
||||
match port.name.as_str() {
|
||||
"input_FL" => output_device.input_fl = Some(port),
|
||||
"input_FR" => output_device.input_fr = Some(port),
|
||||
|
||||
Reference in New Issue
Block a user