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

Impl Serialize/Deserialize for ! #544

Closed
tikue opened this issue Sep 6, 2016 · 3 comments
Closed

Impl Serialize/Deserialize for ! #544

tikue opened this issue Sep 6, 2016 · 3 comments

Comments

@tikue
Copy link

tikue commented Sep 6, 2016

Serialize is straightforward. As for Deserialize, I guess it would just panic? This is useful for me when serializing and deserializing types like Result<T, !>.

@dtolnay
Copy link
Member

dtolnay commented Sep 7, 2016

If we do Deserialize for ! it should error, not panic.

Is Result<T, !> the only instance where you need this? Would it make more sense to specialize De/Serialize for Result<T, !> instead of implementing them for !? Result<T, !> is equivalent to T so we might as well serialize it the same way.

@tikue
Copy link
Author

tikue commented Sep 7, 2016

The Result<T, !> was actually a simplified example. My actual use case involves an error type where one variant is generic: the actual type being deserialized is Result<T, Error<!>>. Basically, if a user implements a service that can never return an application error, the application error is !, and the framework error is Error<!>.

@tikue
Copy link
Author

tikue commented Sep 7, 2016

That being said, it could definitely make sense to specialize the Result<T, !> case as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants