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