Challenges of Supporting Asynchronous and Synchronous Code in Rust
The bane of my existence: Supporting both async and sync code in Rust ๐
The article discusses the challenges of supporting both asynchronous and synchronous code in Rust, using the example of creating a library to wrap a public API. The author initially faced difficulties in accommodating both async and sync usage, leading to code duplication and complexity. They explored various solutions, including manual copy-pasting, using block_on to make async code synchronous, and even considering separate crates for async and sync usage. Ultimately, they found success with the "maybe_async" crate, which allowed them to support multiple HTTP clients independently of their async/sync nature. However, they encountered a fundamental problem with feature conflicts in Rust, which led to discussions about potential solutions and the limitations of current approaches. The author reflects on the challenges and complexities involved in supporting both async and sync code and considers potential future directions for addressing these issues in Rust.
- The author faces challenges in supporting both async and sync code in Rust for a library wrapping a public API.
- They explore different solutions including manual copy-pasting, using block_on, and considering separate crates, before finding success with the "maybe_async" crate.
- Feature conflicts in Rust present a fundamental problem, leading to discussions about potential solutions and the limitations of current approaches.
- The author reflects on the challenges and complexities involved in supporting both async and sync code and considers potential future directions for addressing these issues in Rust.