From 13573941cca891bcf7fa5b61b5816178658bc339 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Sat, 8 May 2021 21:37:48 +0200 Subject: Make (most) pulse nullptr checks unnecessary. This change makes respective functions return either a result or an option instead. The goal here is readability. --- pulse/src/runnable/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pulse/src/runnable/mod.rs') diff --git a/pulse/src/runnable/mod.rs b/pulse/src/runnable/mod.rs index 612bca9..149e994 100644 --- a/pulse/src/runnable/mod.rs +++ b/pulse/src/runnable/mod.rs @@ -4,13 +4,13 @@ use swaystatus_plugin::*; use crate::communication::*; pub mod pulse; -use pulse::Pulse; +use pulse::{Pulse,MainLoopCreationError}; pub struct PulseVolumeRunnable<'p> { config : &'p PulseVolumeConfig, to_main : Box, from_main : Receiver, - pulse : Pulse + pulse : Result } impl<'p : 's, 's> PulseVolumeRunnable<'p> { @@ -20,9 +20,9 @@ impl<'p : 's, 's> PulseVolumeRunnable<'p> { config, to_main, from_main : r, - pulse: Pulse::init(&config.sink), + pulse: Pulse::create() }; - let sender = SenderForMain::new(s, result.pulse.get_wake_up()); + let sender = SenderForMain::new(s, result.pulse.as_ref().map_or(None,|x| Some(x.get_wake_up()))); (result, sender) } } -- cgit v1.2.3