diff --git a/gio/src/cancellable.rs b/gio/src/cancellable.rs index 3ed1ca9a5386..1423d4b32930 100644 --- a/gio/src/cancellable.rs +++ b/gio/src/cancellable.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use std::num::NonZeroU64; +use std::{future::IntoFuture, num::NonZeroU64}; use futures_channel::oneshot; use futures_core::Future; @@ -146,6 +146,26 @@ pub trait CancellableExtManual: IsA { impl> CancellableExtManual for O {} +impl IntoFuture for Cancellable { + type Output = (); + + type IntoFuture = std::pin::Pin + Send + Sync + 'static>>; + + fn into_future(self) -> Self::IntoFuture { + self.future() + } +} + +impl IntoFuture for &Cancellable { + type Output = (); + + type IntoFuture = std::pin::Pin + Send + Sync + 'static>>; + + fn into_future(self) -> Self::IntoFuture { + self.future() + } +} + #[cfg(test)] mod tests { use super::*;