feat: reimplement hash_map! macro#154322
Conversation
Co-authored-by: stifskere <esteve@memw.es>
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| }}; | ||
|
|
||
| ( $( $key:expr => $value:expr ),* $(,)? ) => {{ | ||
| let mut map = $crate::collections::HashMap::with_capacity( |
There was a problem hiding this comment.
I'm curious as to why this is implemented this way instead of using the From<[T;N]> impl. Wouldn't that be simpler, as it would remove the need for the repetition count machinery?
There was a problem hiding this comment.
see this comment on the thread of the original implementation
There was a problem hiding this comment.
Hah, yeah that's a good reason
|
Reminder, once the PR becomes ready for a review, use |
|
there's a test already in library/std/tests, which was added in #148049, or do you mean a different test? @rustbot ready (i think) |
|
That works. Thanks for finding it! @bors r+ rollup |
…uwer Rollup of 11 pull requests Successful merges: - #154074 (don't drop arguments' temporaries in `dbg!`) - #154328 (rustdoc: add missing {os,target,target_env} values for cfg pretty printer) - #154540 (Fix invalid type suggestion for item nested in function) - #154549 (Add regression test for recursive lazy type alias normalization ICE) - #153373 (Fix LegacyKeyValueFormat report from docker build: powerpc) - #154322 (feat: reimplement `hash_map!` macro) - #154416 (Add `IoSplit` diagnostic item for `std::io::Split`) - #154486 (std_detect on AArch64 Darwin: Detect FEAT_SVE_B16B16) - #154508 (Fix ambiguous parsing in bootstrap.py) - #154518 (Panic in Hermit clock_gettime) - #154530 (update zulip link in `std` documentation)
Rollup merge of #154322 - m4rch3n1ng:hash-map-macro, r=Mark-Simulacrum feat: reimplement `hash_map!` macro originally implemented in #144070, this had to be reverted in #148049 due to name ambiguity, as the macro was automatically put into the prelude. now, that #139493 has landed, it is possible to have a top-level macro, that is not exported by default, which should make it possible to reland this again. implements #144032 implementation from #144070, original author has been added as co-author effectively reverts #148049
…uwer Rollup of 11 pull requests Successful merges: - rust-lang/rust#154074 (don't drop arguments' temporaries in `dbg!`) - rust-lang/rust#154328 (rustdoc: add missing {os,target,target_env} values for cfg pretty printer) - rust-lang/rust#154540 (Fix invalid type suggestion for item nested in function) - rust-lang/rust#154549 (Add regression test for recursive lazy type alias normalization ICE) - rust-lang/rust#153373 (Fix LegacyKeyValueFormat report from docker build: powerpc) - rust-lang/rust#154322 (feat: reimplement `hash_map!` macro) - rust-lang/rust#154416 (Add `IoSplit` diagnostic item for `std::io::Split`) - rust-lang/rust#154486 (std_detect on AArch64 Darwin: Detect FEAT_SVE_B16B16) - rust-lang/rust#154508 (Fix ambiguous parsing in bootstrap.py) - rust-lang/rust#154518 (Panic in Hermit clock_gettime) - rust-lang/rust#154530 (update zulip link in `std` documentation)
originally implemented in #144070, this had to be reverted in #148049 due to name ambiguity, as the macro was automatically put into the prelude. now, that #139493 has landed, it is possible to have a top-level macro, that is not exported by default, which should make it possible to reland this again.
implements #144032
implementation from #144070, original author has been added as co-author
effectively reverts #148049