use super::*;
trait LifetimeTest<'a, K: FutureForm> {
fn get_ref(&self) -> K::Future<'_, &'a str>;
}
struct LifetimeType<'a, K> {
data: &'a str,
_marker: PhantomData<K>,
}
#[future_form(Sendable, Local)]
impl<'a, K: FutureForm> LifetimeTest<'a, K> for LifetimeType<'a, K> {
fn get_ref(&self) -> K::Future<'_, &'a str> {
let data = self.data;
K::from_future(async move { data })
}
}
#[tokio::test]
async fn test_lifetime_param_sendable() {
let data = String::from("hello");
let t: LifetimeType<'_, Sendable> = LifetimeType {
data: &data,
_marker: PhantomData,
};
let result = <LifetimeType<'_, Sendable> as LifetimeTest<'_, Sendable>>::get_ref(&t).await;
assert_eq!(result, "hello");
}
#[tokio::test]
async fn test_lifetime_param_local() {
let data = String::from("hello");
let t: LifetimeType<'_, Local> = LifetimeType {
data: &data,
_marker: PhantomData,
};
let result = <LifetimeType<'_, Local> as LifetimeTest<'_, Local>>::get_ref(&t).await;
assert_eq!(result, "hello");
}