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 into_* methods to Value #34

Merged
merged 1 commit into from
Jan 8, 2022
Merged

Conversation

dodomorandi
Copy link
Contributor

I propose the implementation of into_ helpers for Value. I opted for some design choices, which can reconsider without problem:

  • Return values are Results, and the Err type is Self. In this way the value is not lost if the conversion fails. Maybe it is a bit less ergonomic than returning Option, but it should be slightly more powerful.
  • I used Self in Err, but Value in Ok for nested things like Array and Map. This is only to avoid types like Return<Vec<Self>, Self>, which can be slightly confusing.
  • I decided to implement into_ methods for Copy types as well. I made it for consistency, but to be honest I am a bit unsure.
  • I omitted into_null, which would have the following signature:
    fn into_null(self) -> Result<(), Self>
    I think that this would be pretty useless.

Let me know what do you think, I will be happy to receive feedback, discuss and change things in order to expose a nice API.

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.

None yet

5 participants