fix(core): SymbolCharset needs content="value" for Custom(String)

Same latent bug as TrashRetention/HistoryRetention — serde's
internally-tagged repr cannot merge a newtype primitive payload
into a tag object. Add regression test for Custom round-trip.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken
2026-04-19 15:01:09 -04:00
parent 266761232d
commit b2d8a759ef

View File

@@ -95,7 +95,7 @@ pub struct CharClasses {
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")] #[serde(tag = "kind", content = "value", rename_all = "snake_case")]
pub enum SymbolCharset { pub enum SymbolCharset {
SafeOnly, SafeOnly,
Extended, Extended,
@@ -170,4 +170,15 @@ mod tests {
_ => panic!("expected Random default"), _ => panic!("expected Random default"),
} }
} }
#[test]
fn symbol_charset_custom_round_trips() {
let c = SymbolCharset::Custom("!@#".into());
let json = serde_json::to_string(&c).unwrap();
let parsed: SymbolCharset = serde_json::from_str(&json).unwrap();
match parsed {
SymbolCharset::Custom(s) => assert_eq!(s, "!@#"),
other => panic!("expected Custom, got {:?}", other),
}
}
} }