Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Cannot deserialize skip_serializing_if field #326

@WiSaGaN

Description

@WiSaGaN

ipc-channel fails to decode when the type contains skip_serializing_if. I expect below to pass but it fails.

use serde::{Deserialize, Serialize};

#[derive(Deserialize, Serialize)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Foo {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bar: Option<()>,
}

#[cfg(test)]
mod tests {
    use super::*;

    fn foo() -> Foo {
        Foo {
            bar: None,
        }
    }

    #[test]
    fn bincode_roundtrip() {
        let f = foo();
        let s = bincode::serialize(&f).unwrap();
        let new_f = bincode::deserialize(&s).unwrap();
        assert_eq!(f, new_f);
    }
}

I didn't find any issue in bincode, but found serde-rs/serde#1732
Maybe it would be great this gets mentioned in usage documentation before there is a reasonable solution?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions