Skip to content

Commit 14bf64f

Browse files
committed
Wrap IntoFuture around Cancellable::future
Implement IntoFuture for Cancellable as a dead-simple wrapper around the existing Cancellable::future. See #1512
1 parent fec12a0 commit 14bf64f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

gio/src/cancellable.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
use std::num::NonZeroU64;
3+
use std::{future::IntoFuture, num::NonZeroU64};
44

55
use futures_channel::oneshot;
66
use futures_core::Future;
@@ -146,6 +146,16 @@ pub trait CancellableExtManual: IsA<Cancellable> {
146146

147147
impl<O: IsA<Cancellable>> CancellableExtManual for O {}
148148

149+
impl IntoFuture for Cancellable {
150+
type Output = ();
151+
152+
type IntoFuture = std::pin::Pin<Box<dyn Future<Output = ()> + Send + Sync + 'static>>;
153+
154+
fn into_future(self) -> Self::IntoFuture {
155+
self.future()
156+
}
157+
}
158+
149159
#[cfg(test)]
150160
mod tests {
151161
use super::*;

0 commit comments

Comments
 (0)