add a plist macro - copied from serde_json#143
add a plist macro - copied from serde_json#143aluedeke wants to merge 6 commits intoebarnard:masterfrom
Conversation
ebarnard
left a comment
There was a problem hiding this comment.
Thanks for this, it looks really useful. Please could you add some tests for the macro (hopefully can be copied from serde_json as well.
|
@ebarnard added tests as well
|
| // Any Serialize type: numbers, strings, struct literals, variables etc. | ||
| // Must be below every other rule. | ||
| ($other:expr) => { | ||
| $crate::to_value(&$other).unwrap() |
There was a problem hiding this comment.
this actually requires the serde feature @ebarnard should we put the whole macro behind that the serde feature?
There was a problem hiding this comment.
I'd be tempted to initially limit this to things that implement Into<Value>. If someone wants to serialise something they can always call to_value on it themselves.
|
@ebarnard anything else i can do to make it easier to merge this? |
ebarnard
left a comment
There was a problem hiding this comment.
Hi. Sorry this took me so long to get round to looking at. I think it looks good to go barring a few nits.
| // Any Serialize type: numbers, strings, struct literals, variables etc. | ||
| // Must be below every other rule. | ||
| ($other:expr) => { | ||
| $crate::to_value(&$other).unwrap() |
There was a problem hiding this comment.
I'd be tempted to initially limit this to things that implement Into<Value>. If someone wants to serialise something they can always call to_value on it themselves.
| /// }); | ||
| /// ``` | ||
| /// | ||
| /// Variables or expressions can be interpolated into the PList literal. Any type |
There was a problem hiding this comment.
Maybe "Variables or expressions can be interpolated into the literal"? There are no nice casings of "plist".
| @@ -0,0 +1,288 @@ | |||
| /// Construct a `plist::Value` from a JSON literal. | |||
There was a problem hiding this comment.
How about "Construct a plist::Value from a JSON-like literal."? As some things will serialise differently to JSON.
i copied the json macro from serde and modified it i create plist::Value from json annotation. This is super handy when working with lockdown and usbmuxd messages.
I am relatively new to rust, thus i would appreciate any feedback.
The original macro was copied from here:
https://github.com/serde-rs/json/blob/c4f24f3be29a3d096d3ac7b1d5594777a613ec0d/src/macros.rs