use super::*;
trait WorksOK<K: FutureForm> {
fn compute(&self) -> K::Future<'_, u32>;
}
struct MyType<K>(PhantomData<K>);
#[future_form(Sendable, Local)]
impl<K: FutureForm> WorksOK<K> for MyType<K> {
fn compute(&self) -> K::Future<'_, u32> {
K::from_future(async { 42 })
}
}
#[tokio::test]
async fn test_works_ok_sendable() {
let m: MyType<Sendable> = MyType(PhantomData);
let result = <MyType<Sendable> as WorksOK<Sendable>>::compute(&m).await;
assert_eq!(result, 42);
}
#[tokio::test]
async fn test_works_ok_local() {
let m: MyType<Local> = MyType(PhantomData);
let result = <MyType<Local> as WorksOK<Local>>::compute(&m).await;
assert_eq!(result, 42);
}
trait CheckOK<K: FutureForm> {
fn check(&self) -> K::Future<'_, bool>;
}
struct CheckerOK<K>(PhantomData<K>);
#[future_form(Sendable, Local)]
impl<K: FutureForm> CheckOK<K> for CheckerOK<K> {
fn check(&self) -> K::Future<'_, bool> {
K::from_future(async { true })
}
}
#[tokio::test]
async fn test_checker_ok_sendable() {
let c: CheckerOK<Sendable> = CheckerOK(PhantomData);
let result = <CheckerOK<Sendable> as CheckOK<Sendable>>::check(&c).await;
assert!(result);
}
#[tokio::test]
async fn test_checker_ok_local() {
let c: CheckerOK<Local> = CheckerOK(PhantomData);
let result = <CheckerOK<Local> as CheckOK<Local>>::check(&c).await;
assert!(result);
}