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

Add Support for Deserializing newtype struct #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

brettjnorris
Copy link

This resolves an issue I discovered where deserializing a newtype struct throws an error.

Given:

...

#[derive(Serialize, Deserialize)]
struct Id(u8);

export! {
    fn deserialize_id(id: Id) -> Id {
        id
    }
}

Calling the function throws this error:

Error: Error(Msg("invalid type: integer `1`, expected tuple struct Id"), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })

This change here resolves that error by adding a function to explicitly deserialize the newtype struct instead of passing to deserialize_any. I'm open feedback on whether this is the correct approach or if this can be improved on.

brettjnorris and others added 2 commits October 8, 2020 20:18
This adds support for deserializing newtypes
oeed added a commit to oeed/neon-serde that referenced this pull request Feb 23, 2021
This should be fixed properly by merging GabrielCastro#63
@oeed
Copy link

oeed commented Feb 23, 2021

I can confirm I had the same issue and this does indeed solve it.

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

Successfully merging this pull request may close these issues.

2 participants