use super::*;
trait MultiGeneric<K: FutureForm, T> {
fn describe(&self) -> K::Future<'_, String>;
}
struct MultiGenericType<K, T> {
value: T,
_k: PhantomData<K>,
}
#[future_form(Sendable where T: Send, Local)]
impl<K: FutureForm, T: ToString + Clone> MultiGeneric<K, T> for MultiGenericType<K, T> {
fn describe(&self) -> K::Future<'_, String> {
let v = self.value.clone();
K::from_future(async move { v.to_string() })
}
}
#[tokio::test]
async fn test_multi_generic_sendable() {
let t: MultiGenericType<Sendable, i32> = MultiGenericType {
value: 42,
_k: PhantomData,
};
let result =
<MultiGenericType<Sendable, i32> as MultiGeneric<Sendable, i32>>::describe(&t).await;
assert_eq!(result, "42");
}
#[tokio::test]
async fn test_multi_generic_local() {
let t: MultiGenericType<Local, i32> = MultiGenericType {
value: 42,
_k: PhantomData,
};
let result = <MultiGenericType<Local, i32> as MultiGeneric<Local, i32>>::describe(&t).await;
assert_eq!(result, "42");
}