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

Integer base annotations are dropped in certain contexts #5

Open
jon-flatley opened this issue Nov 2, 2022 · 0 comments
Open

Integer base annotations are dropped in certain contexts #5

jon-flatley opened this issue Nov 2, 2022 · 0 comments

Comments

@jon-flatley
Copy link
Collaborator

With the following set of structs, the goal is to get the u64 in E::Value to serialize in hex format. The only place where the #[annotate(format = hex)] attribute seems to accomplish this is when it's attached to myB in C.

#[derive(Annotate, Serialize)]
#[serde(untagged)]
pub enum E {
    // We want this u64 to serialize in hex format.
    Value(u64),
}

#[derive(Annotate, Serialize)]
pub struct A {
    myEnum: E,
}

#[derive(Annotate, Serialize)]
pub struct B {
    myA: Option<Vec<A>>,
}

#[derive(Annotate, Serialize)]
pub struct C {
    #[annotate(format = hex)]
    myB: Vec<B>,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant