You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::collections::HashMap;use serde::Deserialize;#[derive(PartialEq,Eq,Hash,Debug,Deserialize)]structNewType(String);fnmain() -> anyhow::Result<()>{let map = toml::from_str::<HashMap<NewType,u32>>(r#" x = 1 y = 2 "#)?;println!("{map:?}");Ok(())}
Error: TOML parse error at line 2, column 5
|
2 | x = 1
| ^
invalid type: string "x", expected tuple struct NewType
A newtype - a named single-tuple type - cannot be used as the key of a
HashMap
or aBTreeMap
.playground
This is contrary to
serde_json
.playground
I ran into this issue in my project, and I think that this should definitely be supported.
The text was updated successfully, but these errors were encountered: