You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a toplevel enum contains a nested enum both are provided with the "#[serde(tag = "type")]" and the nested enum contains, among other things, an anonymous string, an error occurs during serialisation:
Error("cannot serialize tagged newtype variant EnumNested::WithString containing a string"
-> let serialized = serde_json::to_string_pretty(&enum_type).unwrap();
running 1 test
test tests::test_struct_output_v1 ... FAILED
failures:
---- tests::test_struct_output_v1 stdout ----
thread 'tests::test_struct_output_v1' panicked at 'called Result::unwrap() on an Err value: Error("cannot serialize tagged newtype variant EnumNested::WithString containing a string", line: 0, column: 0)', src/lib.rs:34:71
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
failures:
tests::test_struct_output_v1
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
The text was updated successfully, but these errors were encountered:
This is working correctly as far as I can tell. https://serde.rs/enum-representations.html#internally-tagged documents that tag = "type" is for struct variants, newtype variants containing structs or maps, and unit variants — which is not what WithString is.
If a toplevel enum contains a nested enum both are provided with the "#[serde(tag = "type")]" and the nested enum contains, among other things, an anonymous string, an error occurs during serialisation:
The following error occures:
running 1 test
test tests::test_struct_output_v1 ... FAILED
failures:
---- tests::test_struct_output_v1 stdout ----
thread 'tests::test_struct_output_v1' panicked at 'called
Result::unwrap()
on anErr
value: Error("cannot serialize tagged newtype variant EnumNested::WithString containing a string", line: 0, column: 0)', src/lib.rs:34:71note: run with
RUST_BACKTRACE=1
environment variable to display a backtracefailures:
tests::test_struct_output_v1
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
The text was updated successfully, but these errors were encountered: