continuation

Function continuation 

Source
pub fn continuation<R>() -> (Sender<R>, Future<R>)
Expand description

Creates a new continuation.

If you need to provide a custom cancel implementation, use continuation_cancel instead.

ยงExamples

Basic usage:

use r#continue::continuation;

let (sender, future) = continuation::<String>();

// Send data from another thread
std::thread::spawn(move || {
    sender.send("Hello from another thread!".to_string());
});

// Block on the future to get the result
let result = future.await;
assert_eq!(result, "Hello from another thread!");

Using multiple continuations:

use r#continue::continuation;

// Create multiple continuations
let (tx1, rx1) = continuation::<i32>();
let (tx2, rx2) = continuation::<i32>();

// Send values
tx1.send(42);
tx2.send(100);

// Collect results
let sum = rx1.await + rx2.await;
assert_eq!(sum, 142);