Skip to content

More examples on OneOrMany and newtypes #649

Answered by jonasbb
benjamin-bergia asked this question in Q&A
Discussion options

You must be logged in to vote

Please check if #202 covers your issue too. Basically, if you want to use the default Serialize/Deserialize behavior of a type, you have to write _ within the serde_as attribute. In your case that would be

#[serde_as]
#[derive(Clone, Debug, Deserialize)]
struct ActionList(
    #[serde_as(deserialize_as = "OneOrMany<_, PreferMany>")]
    Vec<Action>
);

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jonasbb
Comment options

You must be logged in to vote
1 reply
@jonasbb
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants