Parsing (1-element) tuple structs into their inner type fail.
#[derive(Deserialize, Serialize, PartialEq, Debug)]
struct UserId(u32);
#[derive(Deserialize, Serialize, PartialEq, Debug)]
struct Query {
user_id: UserId,
}
fn main() {
let query = "user_id=1";
println!("{:?}", from_str::<Query>(query));
// Err(Error { err: "invalid type: string \"1\", expected tuple struct UserId" })
println!("{:?}", to_string(Query{user_id: UserId(1)}));
// Ok("user_id=1")
}
I hope it could do. FYI, serde_json can do it.
Parsing (1-element) tuple structs into their inner type fail.
I hope it could do. FYI, serde_json can do it.