doc fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
382609b04e
commit
7fb49397d5
@ -18,15 +18,22 @@ use crate::tools::async_mutex::{AsyncMutex, AsyncLockGuard, LockFuture};
|
|||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// # use failure::Error;
|
/// # use failure::Error;
|
||||||
/// # use futures::Future;
|
/// # use futures::Future;
|
||||||
/// # fn doc<T: Future<Item = i32, Error = Error>>(future: T) {
|
/// # use proxmox_backup::tools::futures::Cancellable;
|
||||||
/// let cancel = Cancellable::new(future);
|
/// # fn doc<T>(future: T) -> Result<(), Error>
|
||||||
/// let canceller = cancel.canceller(); // This is clonable!
|
/// # where
|
||||||
/// tokio::spawn(cancel.and_then(|res| match res {
|
/// # T: Future<Item = i32, Error = ()> + Send + Sync + 'static,
|
||||||
/// Some(value) => println!("Future finished with {}", value),
|
/// # {
|
||||||
/// None => println!("Future was cancelled"),
|
/// 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
|
/// // Do something
|
||||||
/// canceller.cancel();
|
/// canceller.cancel();
|
||||||
|
/// # Ok(())
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub struct Cancellable<T: Future> {
|
pub struct Cancellable<T: Future> {
|
||||||
|
Loading…
Reference in New Issue
Block a user