Add a hint about deserializing helper params#205
Add a hint about deserializing helper params#205flxo wants to merge 1 commit intosunng87:masterfrom flxo:master
Conversation
|
Sadly I had to add |
src/lib.rs
Outdated
| //! Ok(()) | ||
| //! } | ||
| //! | ||
| //! fn main() {} |
There was a problem hiding this comment.
you can add # to hide this line in doc generation
There was a problem hiding this comment.
Thanks! didn't know. I will hide main and the obvious extern crate ...
|
hi @flxo , this looks like a good and convenient way for accessing json value, with type-safe guarantee. But it has a |
|
@sunng87 I stumbled across the I'm using this pattern in a code generator where the extra deserialisation doesn't hurt nor the |
This addition adds a note about the easy possiblity to work with helper parameters in their original type representation by using `Deserialize`.
|
By the way, how about adding a helper function to |
|
Sounds great, but I think calling pub fn try_into(self) -> Result<T, RenderError> {wouldn't work because it can never be called on a With the pub fn try_into<T: ::serde::de::DeserializeOwned>(&self) -> Result<T, RenderError> {
::serde_json::from_value(self.value.clone())
.map_err(|e| e.into())
} |
This addition adds a note about the easy possiblity to work with helper
parameters in their original type representation by using
Deserialize.