Skip to content
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

bincode::encode_to_vec is incompatible with bincode::serde::encode_to_vec in standard configuration #613

Closed
JanBeh opened this issue Feb 4, 2023 · 1 comment · Fixed by #625

Comments

@JanBeh
Copy link

JanBeh commented Feb 4, 2023

Using version 2.0.0-rc.2, the following code:

fn main() {
    let array: [u8; 3] = [11, 12, 13];
    let stdcfg = bincode::config::standard();
    assert_eq!(
        bincode::encode_to_vec(&array, stdcfg).unwrap(),
        bincode::serde::encode_to_vec(&array, stdcfg).unwrap(),
    );
}

Fails with:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `[3, 11, 12, 13]`,
 right: `[11, 12, 13]`', src/main.rs:6:5

This means bincode::encode_to_vec isn't compatible with bincode::serde::encode_to_vec. This is highly surprising.

See also: How can bincode distinguish between tuples and (fixed size) arrays? on URLO.

@VictorKoenders
Copy link
Contributor

That definitely seems like a bug, thanks for reporting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants