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
I tried to use serde's adjacently tagged serialization of enums with RON. But it does not seem to work. Unless I've something missing. Here is the example:
use serde::{Deserialize,Serialize};#[derive(Serialize,Deserialize)]#[serde(tag = "type", content = "data")]enumTestEnum{Name(String),Index(u32),}fnmain(){use ron::{ser::to_string, de::from_str};let source = TestEnum::Index(1);let ron_string = to_string(&source).unwrap();// this one is oklet deserialized = from_str::<TestEnum>(&ron_string).unwrap();// fails here}
However, the same test for json5 works fine. Am I doing something wrong here?
Here is stack trace:
thread 'main' panicked at 'not implemented: IdDeserializer may only be used for identifiers', <::std::macros::panic macros>:5:6
stack backtrace:
0: backtrace::backtrace::trace_unsynchronized
at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.40\src\backtrace\mod.rs:66
1: std::sys_common::backtrace::_print_fmt
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\sys_common\backtrace.rs:77
2: std::sys_common::backtrace::_print::{{impl}}::fmt
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\sys_common\backtrace.rs:59
3: core::fmt::write
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libcore\fmt\mod.rs:1052
4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\io\mod.rs:1426
5: std::sys_common::backtrace::_print
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\sys_common\backtrace.rs:62
6: std::sys_common::backtrace::print
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\sys_common\backtrace.rs:49
7: std::panicking::default_hook::{{closure}}
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:204
8: std::panicking::default_hook
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:224
9: std::panicking::rust_panic_with_hook
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:472
10: std::panicking::begin_panic_handler
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:380
11: std::panicking::begin_panic_fmt
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:334
12: ron::de::id::{{impl}}::deserialize_str<serde::private::de::content::TagContentOtherFieldVisitor>
at <::std::macros::panic macros>:5
13: serde::private::de::content::{{impl}}::deserialize<mut ron::de::id::IdDeserializer*>
at C:\Users\acanthite\.cargo\registry\src\github.com-1ecc6299db9ec823\serde-1.0.105\src\private\de.rs:981
14: ron::de::{{impl}}::next_key_seed<serde::private::de::content::TagContentOtherFieldVisitor>
at C:\Users\acanthite\.cargo\registry\src\github.com-1ecc6299db9ec823\ron-0.5.1\src\de\mod.rs:546
15: tg::_IMPL_DESERIALIZE_FOR_TestEnum::{{impl}}::deserialize::{{impl}}::visit_map<ron::de::CommaSeparated>
at .\src\main.rs:3
16: ron::de::{{impl}}::deserialize_struct<tg::_IMPL_DESERIALIZE_FOR_TestEnum::{{impl}}::deserialize::__Visitor>
at C:\Users\acanthite\.cargo\registry\src\github.com-1ecc6299db9ec823\ron-0.5.1\src\de\mod.rs:450
17: tg::_IMPL_DESERIALIZE_FOR_TestEnum::{{impl}}::deserialize<mut ron::de::Deserializer*>
at .\src\main.rs:3
18: ron::de::from_bytes<tg::TestEnum>
at C:\Users\acanthite\.cargo\registry\src\github.com-1ecc6299db9ec823\ron-0.5.1\src\de\mod.rs:70
19: ron::de::from_str<tg::TestEnum>
at C:\Users\acanthite\.cargo\registry\src\github.com-1ecc6299db9ec823\ron-0.5.1\src\de\mod.rs:60
20: tg::main
at .\src\main.rs:16
21: std::rt::lang_start::{{closure}}<()>
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\rt.rs:67
22: std::rt::lang_start_internal::{{closure}}
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\rt.rs:52
23: std::panicking::try::do_call<closure-0,i32>
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:305
24: panic_unwind::__rust_maybe_catch_panic
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libpanic_unwind\lib.rs:86
25: std::panicking::try
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panicking.rs:281
26: std::panic::catch_unwind
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\panic.rs:394
27: std::rt::lang_start_internal
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\/src\libstd\rt.rs:51
28: std::rt::lang_start<()>
at /rustc/b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\rt.rs:67
29: main
30: invoke_main
at d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
31: __scrt_common_main_seh
at d:\agent\_work\4\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
32: BaseThreadInitThunk
33: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
The text was updated successfully, but these errors were encountered:
I tried to use serde's adjacently tagged serialization of enums with RON. But it does not seem to work. Unless I've something missing. Here is the example:
However, the same test for json5 works fine. Am I doing something wrong here?
Here is stack trace:
The text was updated successfully, but these errors were encountered: