Skip to content

Commit

Permalink
clippy: complex match condition
Browse files Browse the repository at this point in the history
  • Loading branch information
eladyn committed Mar 15, 2024
1 parent ff2f7a0 commit 1749a04
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/alsa_mixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ impl Mixer for AlsaMixer {

fn volume(&self) -> u16 {
let selem_id = alsa::mixer::SelemId::new(&self.mixer, 0);
match alsa::mixer::Mixer::new(&self.device, false)
.ok()
let mixer = alsa::mixer::Mixer::new(&self.device, false).ok();
let vol = mixer
.as_ref()
.and_then(|mixer| mixer.find_selem(&selem_id))
.and_then(|elem| {
Expand All @@ -58,9 +58,10 @@ impl Mixer for AlsaMixer {
let volume_steps = max - min + 1;
((volume - min) * (0xFFFF / volume_steps)) as u16
})
}) {
});
match vol {
Some(vol) => vol,
_ => {
None => {
error!(
"Couldn't read volume from alsa device with name \"{}\".",
self.device
Expand Down

0 comments on commit 1749a04

Please sign in to comment.