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

Borrow data in Option<Cow<str>> and Option<Cow<[u8]>> with serde(borrow) #2072

Closed
wants to merge 2 commits into from

Conversation

sffc
Copy link

@sffc sffc commented Aug 11, 2021

Fixes #2016

Please see the bug for more information. Thank you in advance!

CC @Manishearth

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

I think this is going to be too niche to be worth building into the serde crate. There are infinite other combinations (like Vec<Cow<str>>) and my feeling is that the current place the line is drawn is appropriate.

There is an external crate that explores composable deserialize_with functions with a way to apply them inside of an Option, Vec etc, so they might be receptive to exposing borrow-based impls for Cow: https://docs.rs/serde_with/1.9.4/serde_with/attr.serde_as.html

@dtolnay dtolnay closed this Aug 21, 2021
@Manishearth
Copy link
Contributor

Ooh, we weren't aware of the serde_with crate, that's neat!

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

Successfully merging this pull request may close these issues.

#[serde(borrow)] does not work with Option<Cow<'a, str>>
3 participants