Open avandecreme opened 4 months ago
With a simple enum type like this one:
#[derive(Debug, Deserialize)] enum Foo { Bar, Baz, }
If the json passed does not have the correct type, the error message is confusing. For example:
let bool_foo = serde_json::from_str::<Foo>("true"); println!("Bool foo: {:?}", bool_foo); // This prints: Bool foo: Err(Error("expected value", line: 1, column: 1))
I would expect the error message to tell that the type is a boolean instead of the expected string.
See the following playground to reproduce together with a custom Deserialize implementation which behave more like I would expect: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=be6d3c0aa282ae7ee1bf5d9748709f4b
With a simple enum type like this one:
If the json passed does not have the correct type, the error message is confusing. For example:
I would expect the error message to tell that the type is a boolean instead of the expected string.
See the following playground to reproduce together with a custom Deserialize implementation which behave more like I would expect: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=be6d3c0aa282ae7ee1bf5d9748709f4b