From 097f726ffdc27a8890981ef180be40a48768f438 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 8 Aug 2025 12:09:21 +0300 Subject: [PATCH] Update rust.instructions.md - async fn in traits More specific about async fn in traits. --- instructions/rust.instructions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/instructions/rust.instructions.md b/instructions/rust.instructions.md index 75ac0e4..26b8f57 100644 --- a/instructions/rust.instructions.md +++ b/instructions/rust.instructions.md @@ -29,6 +29,7 @@ These instructions are based on [The Rust Book](https://doc.rust-lang.org/book/) - Use `serde` for serialization and `thiserror` or `anyhow` for custom errors. - Implement traits to abstract services or external dependencies. - Structure async code using `async/await` and `tokio` or `async-std`. +- When implementing async functions in traits, use native async syntax (Rust 1.75+) by default. Only use the async-trait crate when object-safe traits with dynamic dispatch (dyn Trait) are required. - Prefer enums over flags and states for type safety. - Use builders for complex object creation. - Split binary and library code (`main.rs` vs `lib.rs`) for testability and reuse.