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/communication.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pulse/src/communication.rs') diff --git a/pulse/src/communication.rs b/pulse/src/communication.rs index cfb800e..918d6c9 100644 --- a/pulse/src/communication.rs +++ b/pulse/src/communication.rs @@ -9,11 +9,11 @@ pub enum MessagesFromMain { pub struct SenderForMain { sender : Sender, - pulse_waker : PulseWakeUp + pulse_waker : Option } impl<'p> SenderForMain { - pub fn new(sender : Sender, pulse_waker : PulseWakeUp) -> Self { + pub fn new(sender : Sender, pulse_waker : Option) -> Self { SenderForMain{ sender, pulse_waker @@ -24,7 +24,7 @@ impl<'p> SenderForMain { if let Ok(_) = self.sender.send(message) { //The cool thing about pulse using poll() is that poll() also wakes up if started after //the actual wake up call. So no need to worry about races, this is inherently sane! - self.pulse_waker.wake_up()?; + self.pulse_waker.as_ref().ok_or(PluginCommunicationError {})?.wake_up()?; Ok(()) } else { -- cgit v1.2.3