Crates.io | manual_future |
lib.rs | manual_future |
version | 0.1.1 |
source | src |
created_at | 2019-11-23 22:36:54.029527 |
updated_at | 2019-11-27 18:21:33.069293 |
description | A future that must be manually completed, similar to Java's CompletableFuture |
homepage | https://github.com/dmarcuse/manual_future |
repository | https://github.com/dmarcuse/manual_future.git |
max_upload_size | |
id | 183825 |
size | 8,573 |
Explicitly completed Future
type for Rust, similar to Java's CompletableFuture
// create a new, incomplete ManualFuture
let (future, completer) = ManualFuture::new();
// complete the future with a value
completer.complete(5).await;
// retrieve the value from the future
assert_eq!(future.await, 5);
// you can also create ManualFuture instances that are already completed
assert_eq!(ManualFuture::new_completed(10).await, 10);