next.js
2817a46d - Turbopack: Split DynamicEqHash trait into smaller traits in a separate re-usable crate (#81741)

Commit
192 days ago
Turbopack: Split DynamicEqHash trait into smaller traits in a separate re-usable crate (#81741) I originally split this off to support #81742, but I ended up rewriting that PR to not depend on this... However, I think this is still a code quality improvement, so I'm publishing the PR anyways. A few notable changes: - This is now three traits (`DynPartialEq`, `DynEq`, and `DynHash`) instead of one (`DynamicEqHash`) - The `Dyn` naming instead of `Dynamic` matches the more common Rust convention. - [Trait upcasting is finally stable!](https://blog.rust-lang.org/2025/04/03/Rust-1.86.0/#trait-upcasting) Remove the `.as_any()` idiom. Be very careful with the explicit derefs. - Fix a bug where the type id was getting added to the hash state twice (once by the `Hash` impl, and a second time by the `DynHash` impl). - The `HasherMut` struct isn't really needed, as you can use a `&mut &mut Hasher` instead to work around these dyn compatibility issues in the stdlib. And finally, `MagicAny` is ported to use these `Dyn` traits to dedupe some logic.
Author
bgw bgw
Parents
Loading