Error when deserialize enum with rmp serde
- Dominant language
- Rust
- Stars
- 1.4k
- Forks
- 162
- PR merge metrics
- No merged PRs in 30d
Description
Repo to reproduce error: https://github.com/LooMaclin/reproduce_rmp_serde_deserialize_enum_error
Code example:
```rust
extern crate rmp_serde;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
struct A {
b: B,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "kind", content = "data")]
#[serde(rename_all = "snake_case")]
pub enum B {
First,
Second
}
fn main() {
println!("Hello, world!");
let a = A {
b: B::First,
};
let a = rmp_serde::to_vec(&a).unwrap();
let a: A = rmp_serde::from_slice(&a).unwrap();
println!("a: {:?}", a);
}
```
Error:
```
[loomaclin@loomaclin reproduce_rmp_serde_tagged_enums_error]$ cargo run
Compiling reproduce_rmp_serde_tagged_enums_error v0.1.0 (file:///home/loomaclin/reproduce_rmp_serde_tagged_enums_error)
Finished dev [unoptimized + debuginfo] target(s) in 1.7 secs
Running `target/debug/reproduce_rmp_serde_tagged_enums_error`
Hello, world!
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Syntax("invalid length 1, expected adjacently tagged enum B")', /checkout/src/libcore/result.rs:916:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.
```
rustup show:
```
[loomaclin@loomaclin reproduce_rmp_serde_tagged_enums_error]$ rustup show
Default host: x86_64-unknown-linux-gnu
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu
nightly-2017-09-07-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.24.0-nightly (cddc4a62d 2017-12-26)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.