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

Bad message for struct deserialized from array that is too short #981

Closed
dtolnay opened this issue Jul 9, 2017 · 1 comment
Closed

Bad message for struct deserialized from array that is too short #981

dtolnay opened this issue Jul 9, 2017 · 1 comment
Assignees
Labels

Comments

@dtolnay
Copy link
Member

dtolnay commented Jul 9, 2017

#[macro_use]
extern crate serde_derive;
extern crate serde_json;

#[derive(Deserialize, Debug)]
struct S {
    a: u8,
}

fn main() {
    println!("{}", serde_json::from_str::<S>("[]").unwrap_err());
}

invalid length 0, expected tuple of 1 elements at line 1 column 2

Something like this might be better:

invalid length 0, expected struct S with 1 element at line 1 column 2

@dtolnay
Copy link
Member Author

dtolnay commented May 8, 2018

Fixed in 4ad140e.

@dtolnay dtolnay closed this as completed May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant