Skip to content

Wrap IntoFuture around Cancellable::future #1709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion gio/src/cancellable.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -146,6 +146,26 @@ pub trait CancellableExtManual: IsA<Cancellable> {

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

impl IntoFuture for Cancellable {
type Output = ();

type IntoFuture = std::pin::Pin<Box<dyn Future<Output = ()> + Send + Sync + 'static>>;

fn into_future(self) -> Self::IntoFuture {
self.future()
}
}

impl IntoFuture for &Cancellable {
type Output = ();

type IntoFuture = std::pin::Pin<Box<dyn Future<Output = ()> + Send + Sync + 'static>>;

fn into_future(self) -> Self::IntoFuture {
self.future()
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading