Skip to content

fix(json): serialize BTreeMap keys with unit enum variants#906

Open
leno23 wants to merge 1 commit into
mitsuhiko:masterfrom
leno23:fix/btreemap-enum-json-keys-689
Open

fix(json): serialize BTreeMap keys with unit enum variants#906
leno23 wants to merge 1 commit into
mitsuhiko:masterfrom
leno23:fix/btreemap-enum-json-keys-689

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 17, 2026

Summary

Fixes #689.

assert_json_snapshot! panicked when serializing BTreeMap keys that are unit enum variants (e.g. BTreeMap<MyEnum, bool>). JSON map keys now support UnitVariant names in addition to strings and numeric keys.

Test plan

  • cargo test -p insta --lib test_to_string_unit_variant_keys
  • cargo test -p insta --test test_basic test_btreemap_enum_keys_json --features json
  • CI

Map keys that deserialize as UnitVariant (e.g. BTreeMap<MyEnum, V>)
are now stringified by variant name instead of panicking. Fixes mitsuhiko#689.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BTreeMap json-serialization not supported

1 participant