| 1 |
#![allow(dead_code)] |
| 2 |
|
| 3 |
#[maybe_async::maybe_async] |
| 4 |
trait Trait { |
| 5 |
fn sync_fn() {} |
| 6 |
|
| 7 |
async fn declare_async(&self); |
| 8 |
|
| 9 |
async fn async_fn(&self) { |
| 10 |
self.declare_async().await |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
#[maybe_async::maybe_async] |
| 15 |
pub trait PubTrait { |
| 16 |
fn sync_fn() {} |
| 17 |
|
| 18 |
async fn declare_async(&self); |
| 19 |
|
| 20 |
async fn async_fn(&self) { |
| 21 |
self.declare_async().await |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
#[maybe_async::maybe_async] |
| 26 |
pub(crate) trait PubCrateTrait { |
| 27 |
fn sync_fn() {} |
| 28 |
|
| 29 |
async fn declare_async(&self); |
| 30 |
|
| 31 |
async fn async_fn(&self) { |
| 32 |
self.declare_async().await |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
#[maybe_async::maybe_async] |
| 37 |
async fn async_fn() {} |
| 38 |
|
| 39 |
#[maybe_async::maybe_async] |
| 40 |
pub async fn pub_async_fn() {} |
| 41 |
|
| 42 |
#[maybe_async::maybe_async] |
| 43 |
pub(crate) async fn pub_crate_async_fn() {} |
| 44 |
|
| 45 |
#[maybe_async::maybe_async] |
| 46 |
unsafe fn unsafe_fn() {} |
| 47 |
|
| 48 |
struct Struct; |
| 49 |
|
| 50 |
#[cfg(feature = "is_sync")] |
| 51 |
#[maybe_async::must_be_sync] |
| 52 |
impl Struct { |
| 53 |
fn sync_fn_inherent() {} |
| 54 |
|
| 55 |
async fn declare_async_inherent(&self) {} |
| 56 |
|
| 57 |
async fn async_fn_inherent(&self) { |
| 58 |
async { self.declare_async_inherent().await }.await |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
#[cfg(feature = "is_sync")] |
| 63 |
#[maybe_async::must_be_sync] |
| 64 |
impl Trait for Struct { |
| 65 |
fn sync_fn() {} |
| 66 |
|
| 67 |
async fn declare_async(&self) {} |
| 68 |
|
| 69 |
async fn async_fn(&self) { |
| 70 |
async { self.declare_async().await }.await |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
#[cfg(feature = "is_sync")] |
| 75 |
fn main() -> std::result::Result<(), ()> { |
| 76 |
let s = Struct; |
| 77 |
s.declare_async_inherent(); |
| 78 |
s.async_fn_inherent(); |
| 79 |
s.declare_async(); |
| 80 |
s.async_fn(); |
| 81 |
async_fn(); |
| 82 |
pub_async_fn(); |
| 83 |
Ok(()) |
| 84 |
} |
| 85 |
|
| 86 |
#[cfg(not(feature = "is_sync"))] |
| 87 |
#[async_std::main] |
| 88 |
async fn main() {} |