-
Notifications
You must be signed in to change notification settings - Fork 176
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
Fixing Option borrows (follow-up #1550) #1556
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm but i'd like to wait for shane's review too
feature = "provider_serde", | ||
serde(borrow, with = "serde_with::As::<[serde_with::BorrowCow; 12]>") | ||
)] | ||
pub [Cow<'data, str>; 12], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: is this necessary for [Cow; N]
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
} | ||
); | ||
|
||
#[cfg(all(test, feature = "provider_serde"))] | ||
mod test { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: a cool test to perform (not in this PR) would be to use rust's custom per-collection allocator support to write a wrapping allocator that keeps track of memory allocated, and then construct a postcard based fs/static data provider and deserialize absolutely everything, printing out how much heap memory each component takes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing this!
I'll need to come back to |
// Cows fail to borrow in some situations (array, option), but structs of Cows don't. | ||
pub struct CowWrap<'data>(#[serde(borrow)] Cow<'data, str>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Praise: Nice solution!
Co-authored-by: Shane F. Carr <shane@unicode.org>
No description provided.