From 7fb49397d5793e69085628bdb699e9713ef34a65 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 29 May 2019 11:49:54 +0200 Subject: [PATCH] doc fixup Signed-off-by: Wolfgang Bumiller --- src/tools/futures.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/tools/futures.rs b/src/tools/futures.rs index fb2ec475..2b31164c 100644 --- a/src/tools/futures.rs +++ b/src/tools/futures.rs @@ -18,15 +18,22 @@ use crate::tools::async_mutex::{AsyncMutex, AsyncLockGuard, LockFuture}; /// ```no_run /// # use failure::Error; /// # use futures::Future; -/// # fn doc>(future: T) { -/// let cancel = Cancellable::new(future); -/// let canceller = cancel.canceller(); // This is clonable! -/// tokio::spawn(cancel.and_then(|res| match res { -/// Some(value) => println!("Future finished with {}", value), -/// None => println!("Future was cancelled"), -/// }); +/// # use proxmox_backup::tools::futures::Cancellable; +/// # fn doc(future: T) -> Result<(), Error> +/// # where +/// # T: Future + Send + Sync + 'static, +/// # { +/// let (future, canceller) = Cancellable::new(future)?; +/// tokio::spawn(future.and_then(|res| { +/// match res { +/// Some(value) => println!("Future finished with {}", value), +/// None => println!("Future was cancelled"), +/// } +/// Ok(()) +/// })); /// // Do something /// canceller.cancel(); +/// # Ok(()) /// # } /// ``` pub struct Cancellable {