diff options
Diffstat (limited to 'tests/ui/05-replace-future-generic-type-with-output.rs')
-rw-r--r-- | tests/ui/05-replace-future-generic-type-with-output.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/05-replace-future-generic-type-with-output.rs b/tests/ui/05-replace-future-generic-type-with-output.rs new file mode 100644 index 0000000..2410580 --- /dev/null +++ b/tests/ui/05-replace-future-generic-type-with-output.rs @@ -0,0 +1,34 @@ +#![allow(unused_imports)] +use std::future::Future; + +#[maybe_async::maybe_async] +pub async fn with_fn<T, F: Sync + std::future::Future<Output = Result<(), ()>>>( + test: T, +) -> Result<(), ()> + where + T: FnOnce() -> F, +{ + test().await +} + +#[maybe_async::maybe_async] +pub async fn with_fn_where<T, F>(test: T) -> Result<(), ()> + where + T: FnOnce() -> F, + F: Sync + Future<Output = Result<(), ()>>, +{ + test().await +} + +#[maybe_async::sync_impl] +fn main() { + with_fn(|| Ok(())).unwrap(); + with_fn_where(|| Ok(())).unwrap(); +} + +#[maybe_async::async_impl] +#[tokio::main] +async fn main() { + with_fn(|| async { Ok(()) }).await.unwrap(); + with_fn_where(|| async { Ok(()) }).await.unwrap(); +} |