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 Serialize/Deserialize for Option<DateTime> #302

Merged
merged 2 commits into from Nov 22, 2019

Conversation

manifest
Copy link
Contributor

This PR for the issue.

@manifest manifest force-pushed the feature/option branch 4 times, most recently from 3c67fdc to 008ba67 Compare January 27, 2019 16:49
@manifest
Copy link
Contributor Author

One test for Rust 1.13.0 fails on

error: unions are unstable and possibly buggy (see issue #32836)
   --> /Users/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.48/src/macros.rs:42:13
    |
42  |             pub $t $i { $($field)* }
    |             ^^^^^^^^^^^^^^^^^^^^^^^^
    | 
   ::: /Users/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.48/src/lib.rs
    |
177 | cfg_if! {
    | - in this macro invocation
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
error: Could not compile `libc`.

I'm not sure where it comes from. It seems unrelated to this PR.

@quodlibetor
Copy link
Contributor

yeah that error is coming from libc, the most recent version doesn't support rust 1.13. I'm not sure what the best way to handle that is, but it's not something you have to worry about.

@manifest
Copy link
Contributor Author

@quodlibetor Is there anything that need to be done to have this one merged?

@JMLX42
Copy link

JMLX42 commented Apr 3, 2019

+1 can we merge this?

@quodlibetor
Copy link
Contributor

Sorry about the delay, I feel like there ought to be a better way to do this, since currently using an option can be done pretty trivially #125 (comment) .

So, (A) I would rather this was already more ergonomic, and (B) maybe it would be better to do something that doesn't add quite as much API surface/code that requires maintenance.

@JMLX42
Copy link

JMLX42 commented Apr 9, 2019

@quodlibetor maybe I missed something but the code in #125 (comment) doesn't work for me.

It throws with Json(Error("missing field revisionDate")) when the field is missing.

IMHO because the proposed code in your comment does not actually handle the case when the field is not here. Which is the whole point behind Option<DateTime<Utc>>.

So AFAIK this PR is still required and very useful.

@JMLX42
Copy link

JMLX42 commented Apr 10, 2019

My bad: the suggested solution in #125 (comment) works if I add #[serde(default)] to the corresponding field.

@quodlibetor
Copy link
Contributor

Looks good enough to merge, we can make the code-size smaller in a future commit.

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

3 participants