-
Notifications
You must be signed in to change notification settings - Fork 114
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 serde serialization support #210
add serde serialization support #210
Conversation
78010f6
to
868c118
Compare
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.
Thanks! And sorry for the delay giving feedback on this. A handful of comments below.
tests/all/boxed.rs
Outdated
let boxed = Box::new_in(1, &bump); | ||
assert_eq!(serde_json::to_string(&boxed).unwrap(), "1"); | ||
let boxedStr = Box::new_in("a", &bump); | ||
assert_eq!(serde_json::to_string(&boxedStr).unwrap(), "\"a\""); |
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.
Can we also test a few other things:
- tuple
- struct w/ a couple fields
- enum w/ a couple variants
- vec w/ a couple elements
- hash map
- hash set
It should be fine to add a dev dependency on serde_derive
if it makes this easier, fwiw.
Also, no need to explicitly write out the expected JSON; should be able to call serde_json::to_string(&unboxed_value)
and then serde_json::to_string(&boxed_value)
and compare the results for equality, I believe. Or compare std::boxed::Box<T>
with bumpalo::boxed::Box<'_, T>
. Might be worth writing a little helper that does this dance, rather than writing it out in full for all the cases above.
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.
I've added a struct with an enum and option. Hopefully that's sufficient, or would you like me to add more such as the hash map/set?
868c118
to
3596757
Compare
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.
Thanks!
This starts work on #63 by adding support for
Serialize
onBox
andVec
, with some basic tests & docs.I couldn't figure out the right way to implement
DeserializeSeed
forVec
. I'm a newcommer to rust so I think I need some pointers on how to handle that, as I'm struggling with lifetimes: