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

serde_test 1.0.20+ fails on Struct len check #15

Closed
bradleybeddoes opened this issue Nov 19, 2017 · 1 comment
Closed

serde_test 1.0.20+ fails on Struct len check #15

bradleybeddoes opened this issue Nov 19, 2017 · 1 comment
Labels
bug Something isn't working

Comments

@bradleybeddoes
Copy link

This appears to be failing because the struct in question makes use of skip_serializing_if = Option::is_none.

Here is an example which passes prior to serde_test 1.0.20

    #[derive(Serialize, Deserialize, PartialEq, Debug)]
    struct A {
        pub x: u8,

        #[serde(default, skip_serializing_if = "Option::is_none")]
        pub y: Option<u8>,
    }

    #[test]
    pub fn test_struct_a() {
        let a = A { x: 1, y: None };

        assert_tokens(
            &a,
            &[
                Token::Struct { name: "A", len: 1 },
                Token::Str("x"),
                Token::U8(1),
                Token::StructEnd,
            ],
        );
    }

The result from a test run is:

... 
panicked at 'expected Token::Struct { name: "A", len: 1 } but deserialization wants Token::Struct { name: "A", len: 2 }'
...
@dtolnay dtolnay added the bug Something isn't working label Nov 30, 2017
@dtolnay
Copy link
Member

dtolnay commented Nov 30, 2017

Thanks, I reverted the change in eb6bf16a5191df1e736619a8dd2a05749c86b8df and released serde_test 1.0.23.

@dtolnay dtolnay closed this as completed Nov 30, 2017
@dtolnay dtolnay transferred this issue from serde-rs/serde Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants