| 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(?Send)] |
| 15 |
trait NotSendTrait { |
| 16 |
async fn declare_async_not_send(&self); |
| 17 |
|
| 18 |
async fn async_fn_not_send(&self) { |
| 19 |
self.declare_async_not_send().await |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
#[maybe_async::maybe_async] |
| 24 |
pub trait PubTrait { |
| 25 |
fn sync_fn() {} |
| 26 |
|
| 27 |
async fn declare_async(&self); |
| 28 |
|
| 29 |
async fn async_fn(&self) { |
| 30 |
self.declare_async().await |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
#[maybe_async::maybe_async] |
| 35 |
pub(crate) trait PubCrateTrait { |
| 36 |
fn sync_fn() {} |
| 37 |
|
| 38 |
async fn declare_async(&self); |
| 39 |
|
| 40 |
async fn async_fn(&self) { |
| 41 |
self.declare_async().await |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
#[maybe_async::maybe_async(AFIT)] |
| 46 |
trait AfitTrait { |
| 47 |
fn sync_fn_afit() {} |
| 48 |
|
| 49 |
async fn declare_async_afit(&self); |
| 50 |
|
| 51 |
async fn async_fn_afit(&self) { |
| 52 |
self.declare_async_afit().await |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
#[cfg(not(feature = "is_sync"))] |
| 57 |
#[maybe_async::must_be_async] |
| 58 |
async fn async_fn() {} |
| 59 |
|
| 60 |
#[cfg(not(feature = "is_sync"))] |
| 61 |
#[maybe_async::must_be_async] |
| 62 |
pub async fn pub_async_fn() {} |
| 63 |
|
| 64 |
#[cfg(not(feature = "is_sync"))] |
| 65 |
#[maybe_async::maybe_async] |
| 66 |
pub(crate) async fn pub_crate_async_fn() {} |
| 67 |
|
| 68 |
#[cfg(not(feature = "is_sync"))] |
| 69 |
#[maybe_async::maybe_async] |
| 70 |
unsafe fn unsafe_fn() {} |
| 71 |
|
| 72 |
struct Struct; |
| 73 |
|
| 74 |
#[cfg(not(feature = "is_sync"))] |
| 75 |
#[maybe_async::must_be_async] |
| 76 |
impl Struct { |
| 77 |
fn sync_fn_inherent() {} |
| 78 |
|
| 79 |
async fn declare_async_inherent(&self) {} |
| 80 |
|
| 81 |
async fn async_fn_inherent(&self) { |
| 82 |
async { self.declare_async_inherent().await }.await |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
#[cfg(not(feature = "is_sync"))] |
| 87 |
#[maybe_async::must_be_async] |
| 88 |
impl Trait for Struct { |
| 89 |
fn sync_fn() {} |
| 90 |
|
| 91 |
async fn declare_async(&self) {} |
| 92 |
|
| 93 |
async fn async_fn(&self) { |
| 94 |
async { self.declare_async().await }.await |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
#[cfg(not(feature = "is_sync"))] |
| 99 |
#[maybe_async::must_be_async(?Send)] |
| 100 |
impl NotSendTrait for Struct { |
| 101 |
async fn declare_async_not_send(&self) {} |
| 102 |
|
| 103 |
async fn async_fn_not_send(&self) { |
| 104 |
async { self.declare_async_not_send().await }.await |
| 105 |
} |
| 106 |
} |
| 107 |
#[cfg(not(feature = "is_sync"))] |
| 108 |
#[maybe_async::must_be_async(AFIT)] |
| 109 |
impl AfitTrait for Struct { |
| 110 |
fn sync_fn_afit() {} |
| 111 |
|
| 112 |
async fn declare_async_afit(&self) {} |
| 113 |
|
| 114 |
async fn async_fn_afit(&self) { |
| 115 |
async { self.declare_async_afit().await }.await |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
#[cfg(feature = "is_sync")] |
| 120 |
fn main() {} |
| 121 |
|
| 122 |
#[cfg(not(feature = "is_sync"))] |
| 123 |
#[async_std::main] |
| 124 |
async fn main() { |
| 125 |
let s = Struct; |
| 126 |
s.declare_async_inherent().await; |
| 127 |
s.async_fn_inherent().await; |
| 128 |
s.declare_async().await; |
| 129 |
s.async_fn().await; |
| 130 |
s.declare_async_afit().await; |
| 131 |
s.async_fn_afit().await; |
| 132 |
async_fn().await; |
| 133 |
pub_async_fn().await; |
| 134 |
} |