-
Notifications
You must be signed in to change notification settings - Fork 112
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
Serializing simple enum leads to UnsupportedType
#553
Comments
May be linked to #534. |
All in one reproduction case: #!/usr/bin/env rust-script
//! ```cargo
//! [dependencies]
//! toml = "0.7.3"
//! serde = { version = "1", features = ["derive"] }
//! serde_json = "1"
//! ```
#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct Struct {
field: Enum,
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
enum Enum {
Variant(u8),
}
fn main() {
let ser = Struct {
field: Enum::Variant(21),
};
println!("json: {:?}", serde_json::to_string(&ser));
println!("toml: {:?}", toml::to_string(&ser));
let de: Result<Struct, toml::de::Error> = toml::from_str("[field]\nVariant = 21");
println!("toml: {:?}", de);
} |
epage
added a commit
to epage/toml_edit
that referenced
this issue
May 18, 2023
epage
added a commit
to epage/toml_edit
that referenced
this issue
May 18, 2023
New release out with newtype variant support |
Awesome, thank you!
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry if the answer is obvious, but I cannot understand why
toml
is not able to serialize this struct (butserde_json
can):Even mor surprising, the same struct can be deserialized without any problem:
The text was updated successfully, but these errors were encountered: