Uh oh!
There was an error while loading. Please reload this page.
serialize: impl ToJson for all Encodables - #12936
Conversation
alexcrichton
commented
Mar 17, 2014
I'm a little sad to see yet another encoder in the From what it looks like, the are three different representations that the
This is a bit of a hefty matrix to deal with, and I fear the utility of the
I would imagine that the decoder is what the parser is today, and that this intermediate format of What do you think of this? |
seanmonstar
commented
Mar 17, 2014
Personally, I was surprised to read in #8335 the need to turn a rust object into a I also think the |
alexcrichton
commented
Mar 17, 2014
That sounds good to me! Here's a few things that I think would work well:
That way you use the Decoder to go from a string to a rust value and the Encoder to go from a rust value to a string. Conversion between rust values and a Json value would require going through a string. You can also always decode directly into a Json value if you need to inspect the object. |
seanmonstar
commented
Mar 17, 2014
Why remove the Parser? Looking in |
alexcrichton
commented
Mar 17, 2014
|
seanmonstar
commented
Mar 17, 2014
is there any need to keep the If it does stick around, I can't figure out how I would implement impl<D:Decoder>Decodable<D>forJson{fn(d:&mutD) -> Json{// can i somehow match against types?matchDecodable::decode(d){
f64 => Number,// etc?}}} |
alexcrichton
commented
Mar 18, 2014
Keeping You don't need to implement |
There was a problem hiding this comment.
This should be to_json instead of into_json, or instead it should consume self. We've standardized on using into_ to represent methods that consume self to transform into the result`. Also, this should return an error type instead of failing.
seanmonstar
commented
Mar 18, 2014
I'll open a new PR of json cleanup. I've also found the error handler in Encoder's to unfun, so I might fix #12292 before. |
…r_comparison, r=Alexendoo Add MSRV for manual_pattern_char_comparison Fixesrust-lang#12936 changelog: [`manual_pattern_char_comparison`]: Add MSRV 1.58
I just wanted to submit this at this point to see if something like this would be accepted. If so, I can clean it up some more, such as converting to
Vec<T>, etc.The short is that this is now possible:
fixes#8335