From a3e21fed80cfa1484bb166cb596de83301a57b50 Mon Sep 17 00:00:00 2001 From: Jujstme Date: Fri, 2 Feb 2024 22:58:24 +0100 Subject: [PATCH] Reformatted for futures --- src/emulator/gba/mod.rs | 12 ++++++++---- src/emulator/gcn/mod.rs | 12 ++++++++---- src/emulator/genesis/mod.rs | 14 +++++++++----- src/emulator/ps1/mod.rs | 12 ++++++++---- src/emulator/ps2/mod.rs | 12 ++++++++---- src/emulator/sms/mod.rs | 12 ++++++++---- src/emulator/wii/mod.rs | 12 ++++++++---- 7 files changed, 57 insertions(+), 29 deletions(-) diff --git a/src/emulator/gba/mod.rs b/src/emulator/gba/mod.rs index e454edb..425f33f 100644 --- a/src/emulator/gba/mod.rs +++ b/src/emulator/gba/mod.rs @@ -196,16 +196,20 @@ pub struct UntilEmulatorCloses<'a, F> { future: F, } -impl> Future for UntilEmulatorCloses<'_, F> { - type Output = (); +impl> Future for UntilEmulatorCloses<'_, F> { + type Output = Option; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if !self.emulator.is_open() { - return Poll::Ready(()); + return Poll::Ready(None); } self.emulator.update(); // SAFETY: We are simply projecting the Pin. - unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().future).poll(cx) } + unsafe { + Pin::new_unchecked(&mut self.get_unchecked_mut().future) + .poll(cx) + .map(Some) + } } } diff --git a/src/emulator/gcn/mod.rs b/src/emulator/gcn/mod.rs index 4c483e5..77f18fb 100644 --- a/src/emulator/gcn/mod.rs +++ b/src/emulator/gcn/mod.rs @@ -194,16 +194,20 @@ pub struct UntilEmulatorCloses<'a, F> { future: F, } -impl> Future for UntilEmulatorCloses<'_, F> { - type Output = (); +impl> Future for UntilEmulatorCloses<'_, F> { + type Output = Option; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if !self.emulator.is_open() { - return Poll::Ready(()); + return Poll::Ready(None); } self.emulator.update(); // SAFETY: We are simply projecting the Pin. - unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().future).poll(cx) } + unsafe { + Pin::new_unchecked(&mut self.get_unchecked_mut().future) + .poll(cx) + .map(Some) + } } } diff --git a/src/emulator/genesis/mod.rs b/src/emulator/genesis/mod.rs index 32ad8b2..90fed54 100644 --- a/src/emulator/genesis/mod.rs +++ b/src/emulator/genesis/mod.rs @@ -214,16 +214,20 @@ pub struct UntilEmulatorCloses<'a, F> { future: F, } -impl> Future for UntilEmulatorCloses<'_, F> { - type Output = (); +impl> Future for UntilEmulatorCloses<'_, F> { + type Output = Option; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - if !self.emulator.process.is_open() { - return Poll::Ready(()); + if !self.emulator.is_open() { + return Poll::Ready(None); } self.emulator.update(); // SAFETY: We are simply projecting the Pin. - unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().future).poll(cx) } + unsafe { + Pin::new_unchecked(&mut self.get_unchecked_mut().future) + .poll(cx) + .map(Some) + } } } diff --git a/src/emulator/ps1/mod.rs b/src/emulator/ps1/mod.rs index c0e89f6..3112630 100644 --- a/src/emulator/ps1/mod.rs +++ b/src/emulator/ps1/mod.rs @@ -198,16 +198,20 @@ pub struct UntilEmulatorCloses<'a, F> { future: F, } -impl> Future for UntilEmulatorCloses<'_, F> { - type Output = (); +impl> Future for UntilEmulatorCloses<'_, F> { + type Output = Option; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if !self.emulator.is_open() { - return Poll::Ready(()); + return Poll::Ready(None); } self.emulator.update(); // SAFETY: We are simply projecting the Pin. - unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().future).poll(cx) } + unsafe { + Pin::new_unchecked(&mut self.get_unchecked_mut().future) + .poll(cx) + .map(Some) + } } } diff --git a/src/emulator/ps2/mod.rs b/src/emulator/ps2/mod.rs index 614fe8e..ec4f54c 100644 --- a/src/emulator/ps2/mod.rs +++ b/src/emulator/ps2/mod.rs @@ -171,16 +171,20 @@ pub struct UntilEmulatorCloses<'a, F> { future: F, } -impl> Future for UntilEmulatorCloses<'_, F> { - type Output = (); +impl> Future for UntilEmulatorCloses<'_, F> { + type Output = Option; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if !self.emulator.is_open() { - return Poll::Ready(()); + return Poll::Ready(None); } self.emulator.update(); // SAFETY: We are simply projecting the Pin. - unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().future).poll(cx) } + unsafe { + Pin::new_unchecked(&mut self.get_unchecked_mut().future) + .poll(cx) + .map(Some) + } } } diff --git a/src/emulator/sms/mod.rs b/src/emulator/sms/mod.rs index 7dd9f15..de19f0e 100644 --- a/src/emulator/sms/mod.rs +++ b/src/emulator/sms/mod.rs @@ -154,16 +154,20 @@ pub struct UntilEmulatorCloses<'a, F> { future: F, } -impl> Future for UntilEmulatorCloses<'_, F> { - type Output = (); +impl> Future for UntilEmulatorCloses<'_, F> { + type Output = Option; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if !self.emulator.is_open() { - return Poll::Ready(()); + return Poll::Ready(None); } self.emulator.update(); // SAFETY: We are simply projecting the Pin. - unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().future).poll(cx) } + unsafe { + Pin::new_unchecked(&mut self.get_unchecked_mut().future) + .poll(cx) + .map(Some) + } } } diff --git a/src/emulator/wii/mod.rs b/src/emulator/wii/mod.rs index 512f4df..d3a9e61 100644 --- a/src/emulator/wii/mod.rs +++ b/src/emulator/wii/mod.rs @@ -206,16 +206,20 @@ pub struct UntilEmulatorCloses<'a, F> { future: F, } -impl> Future for UntilEmulatorCloses<'_, F> { - type Output = (); +impl> Future for UntilEmulatorCloses<'_, F> { + type Output = Option; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if !self.emulator.is_open() { - return Poll::Ready(()); + return Poll::Ready(None); } self.emulator.update(); // SAFETY: We are simply projecting the Pin. - unsafe { Pin::new_unchecked(&mut self.get_unchecked_mut().future).poll(cx) } + unsafe { + Pin::new_unchecked(&mut self.get_unchecked_mut().future) + .poll(cx) + .map(Some) + } } }