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

Write custom deserializer function for Option<Cow<str>> #821

Closed
wants to merge 1 commit into from

Conversation

sffc
Copy link
Member

@sffc sffc commented Jun 24, 2021

Workaround for serde-rs/serde#2016

@Manishearth: opinions on where this should go?

@sffc sffc requested a review from Manishearth June 24, 2021 07:24
@codecov-commenter
Copy link

Codecov Report

Merging #821 (1ad8852) into main (2b7ca3b) will increase coverage by 0.09%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #821      +/-   ##
==========================================
+ Coverage   75.34%   75.44%   +0.09%     
==========================================
  Files         197      193       -4     
  Lines       12563    12499      -64     
==========================================
- Hits         9466     9430      -36     
+ Misses       3097     3069      -28     
Impacted Files Coverage Δ
provider/testdata/src/test_data_provider.rs
provider/testdata/src/paths.rs
provider/testdata/src/lib.rs
provider/testdata/src/metadata.rs
experimental/provider_ppucd/src/parse_ppucd.rs 93.13% <0.00%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b7ca3b...1ad8852. Read the comment docs.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1e77bd4636ba5acea5377d8af8f385012fd077ad-PR-821

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.008%) to 75.516%

Totals Coverage Status
Change from base Build 2b7ca3bd55486daafbcf579d05243773e006ec89: 0.008%
Covered Lines: 9558
Relevant Lines: 12657

💛 - Coveralls

Copy link
Member

@Manishearth Manishearth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No opinion on where this should go. Probably worth making it a public export of provider/core? Other data structs will need this, yes?

use std::borrow::Cow;
use std::fmt;

fn deserialize_option_cow_str<'de, D>(deserializer: D) -> Result<Option<Cow<'de, str>>, D::Error>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chore: Probably should have a comment saying why we have this

@sffc
Copy link
Member Author

sffc commented Jun 24, 2021

I can stick it in the icu_provider module, but I'm just a little hesitant to start making icu_provider a bag of random utilities. But maybe there just isn't a better place to use it, and most call sites that need this will be depending on icu_provider.

@Manishearth
Copy link
Member

Yeah I don't have a good answer for you, I don't have strong opinions on where it should go so use your best judgement imo.

@sffc
Copy link
Member Author

sffc commented Jun 24, 2021

2021-06-24:

@sffc sffc added the waiting-on-author PRs waiting for action from the author for >7 days label Jun 28, 2021
@Manishearth
Copy link
Member

I think upstreaming this is going to be unlikely and for now we should just stick this in provider_core.

@Manishearth Manishearth mentioned this pull request Aug 3, 2021
@sffc
Copy link
Member Author

sffc commented Aug 11, 2021

I think upstreaming this is going to be unlikely and for now we should just stick this in provider_core.

Acknowledged, but I made a PR for upstreaming this anyway:

serde-rs/serde#2072

It should be noted that this only affects serde_derive, not serde itself.

@sffc sffc added blocked A dependency must be resolved before this is actionable and removed waiting-on-author PRs waiting for action from the author for >7 days labels Aug 12, 2021
@sffc
Copy link
Member Author

sffc commented Aug 26, 2021

So we may not end up needing this in the short-term because PluralRules is going to be migrated off of Option<Cow>. However, we may need it in the future. I will file a follow-up issue to discuss further.

@robertbastian
Copy link
Member

I need this in #1550, so let's merge? We could put it alongside deduplicating_array in a serde_utils crate.

@sffc
Copy link
Member Author

sffc commented Feb 1, 2022

Superseded by #1556.

@sffc sffc closed this Feb 1, 2022
@sffc sffc deleted the option-cow branch February 1, 2022 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked A dependency must be resolved before this is actionable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants