### Async Main Function with Pollster Macro Source: https://github.com/zesterer/pollster/blob/master/README.md This example shows how to use the `#[pollster::main]` attribute macro to define an asynchronous main function. This macro allows you to write `async fn main()` directly, simplifying the entry point for async applications that use pollster. It's an alternative to manually calling `block_on`. ```rust #[pollster::main] async fn main() { let my_fut = async {}; my_fut.await; } ``` -------------------------------- ### Use `async fn main()` with the pollster macro Source: https://github.com/zesterer/pollster/blob/master/macro/README.md This snippet shows how to use the `pollster::main` attribute macro to mark an async function as the entry point of the program. This simplifies the process of running async code as the main function. The `crate` option can be used if pollster was re-exported with a different name. ```rust #[pollster::main] async fn main() { let my_fut = async {}; my_fut.await; } #[pollster::main(crate = renamed_pollster)] async fn main() { let my_fut = async {}; my_fut.await; } ``` -------------------------------- ### Evaluate a Future to Completion using block_on Source: https://github.com/zesterer/pollster/blob/master/macro/README.md This snippet demonstrates the core functionality of pollster, using the `block_on` method from the `FutureExt` trait to synchronously block the current thread until an async future completes. It requires the `pollster` crate. ```rust use pollster::FutureExt as _; let my_fut = async {}; let result = my_fut.block_on(); ``` -------------------------------- ### Custom Crate Name for Pollster Macro Source: https://github.com/zesterer/pollster/blob/master/README.md This snippet illustrates how to specify a custom crate name when using the `#[pollster::main]` macro. This is necessary if the pollster crate has been re-exported or aliased under a different name within the project. It ensures the macro correctly references the pollster crate's functionality. ```rust #[pollster::main(crate = renamed_pollster)] async fn main() { let my_fut = async {}; my_fut.await; } ``` -------------------------------- ### Use `#[pollster::test]` for async tests Source: https://github.com/zesterer/pollster/blob/master/macro/README.md This snippet illustrates the usage of the `#[pollster::test]` attribute macro for running asynchronous tests. This allows writing tests that involve async operations directly within the test function. ```rust #[pollster::test] async fn my_async_test() { let my_fut = async {}; my_fut.await; assert!(true); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.