-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels