Async function signature

I'm playing with custom_testing_framework and I don't know how to do the following:

Suppose that I want all my ts functions will be async:

#![feature(custom_test_frameworks)]
#![test_runner(crate::my_runner)]

#[cfg(test)]
#[tokio::main]
async fn my_runner(ts: &[&FnOnce() -> ?]) {
// somewhere call for all ts .await
}

#[test_case]
async fn some_test() {}
}

But I can't specify an appropriate returned type for my tests functions.
I tried to use such thing: Higher function taking async reference-taking closures, for rewriting my test's runner function signature to:

async fn my_runner<F>(ts: &[F])
where
     F: for<'a> AsyncFn1<(), Output = ()>,

But in such cases I can't call multiple tests since every function even with same input/output props has a different type.

You can try using a &[dyn AsyncFn<(), Output = ()>]. Not sure if it will work with regards to lifetimes.

I recommend this thread: How to handle a vector of async function pointers

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.