Derive macros are one of the many conveniences offered by Rust, allowing automatic code generation tailored to your data types, with additional customization through attributes. While there don't exist any guidelines for how these attributes should look, perhaps because it seems like a trivial matter, I found myself struggling to decide on the most logical way to structure my attribute macros when working on bin-proto, and decided that a writeup was necessary. This article will provide an overview of the approaches taken by various crates, with some reasoning about what I would deem best.
Derive macros are one of the many conveniences offered by Rust, allowing automatic code generation tailored to your data types, with additional customization through attributes. While there don't exist any guidelines for how these attributes should look, perhaps because it seems like a trivial matter, I found myself struggling to decide on the most logical way to structure my attribute macros when working on bin-proto, and decided that a writeup was necessary. This article will provide an overview of the approaches taken by various crates, with some reasoning about what I would deem best.
what's the best way to deal with dynamic types in Rust?
Using `Arc<Mutex<HashMap<K, V>>>` is often not ideal in Rust due to contention, deadlocks, and performance concerns. For concurrent access patterns, consider using DashMap or RwLock instead, as they provide better performance through finer-grained locking or lock-free mechanisms
Dựa theo link: https://voelklmichael.github.io/Blog/serde-trait-part1.html