use super::*;
trait Callback<K: FutureForm> {
fn call<'a>(&'a self, f: K::Future<'a, u32>) -> K::Future<'a, u32>;
}
struct Passthrough<K>(PhantomData<K>);
#[future_form(Sendable, Local)]
impl<K: FutureForm> Callback<K> for Passthrough<K> {
fn call<'a>(&'a self, f: K::Future<'a, u32>) -> K::Future<'a, u32> {
f
}
}
#[tokio::test]
async fn test_k_in_method_param_sendable() {
let p: Passthrough<Sendable> = Passthrough(PhantomData);
let fut = Sendable::from_future(async { 42 });
let result = <Passthrough<Sendable> as Callback<Sendable>>::call(&p, fut).await;
assert_eq!(result, 42);
}
#[tokio::test]
async fn test_k_in_method_param_local() {
let p: Passthrough<Local> = Passthrough(PhantomData);
let fut = Local::from_future(async { 42 });
let result = <Passthrough<Local> as Callback<Local>>::call(&p, fut).await;
assert_eq!(result, 42);
}