Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing tuple struct #34

Open
KeenS opened this issue May 30, 2018 · 1 comment
Open

Parsing tuple struct #34

KeenS opened this issue May 30, 2018 · 1 comment

Comments

@KeenS
Copy link

KeenS commented May 30, 2018

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.

@nox
Copy link
Owner

nox commented Aug 14, 2018

I would accept a patch for that.

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

No branches or pull requests

2 participants