Aleph-Alpha / ts-rs

Generate TypeScript bindings from Rust types
MIT License
1.15k stars 115 forks source link

Made the TS implementation for hashmap and hashset generic over all hashers #173

Closed VictorKoenders closed 9 months ago

VictorKoenders commented 1 year ago

By default the hasher is RandomState but developers can override this. This PR makes ts-rs usable with e.g. https://docs.rs/rustc-hash/latest/rustc_hash/.

VictorKoenders commented 1 year ago

Added tests for HashMap, HashSet and examples on how to use custom hashers.

It seems like you can't use HashMap<K, V, CustomHasher> directly because the TS derive requires that all type arguments extend from TS. However with a type alias it works perfectly fine.

escritorio-gustavo commented 9 months ago

LGTM. I edited your tests to expect types instead of interfaces due to #203

NyxCode commented 9 months ago

Great! Don't see any problems, here, so let's get this merged. Thanks @VictorKoenders for the PR, and thanks @escritorio-gustavo for taking a look!