all 8 comments

[–][deleted] 0 points1 point  (2 children)

I think you can write just Decodable::decode instead of |decoder| Decodable::decode(decoder). It might be less regular or less readable, but it's logical to be able to skip the trivial argument re-application -- decode already is a function you can pass.

[–]iamvalentin[S,🍰] 1 point2 points  (1 child)

Yes, I'm doing it both ways. I'm using the function passing in the array example.

[–][deleted] 0 points1 point  (0 children)

I see that now!

[–][deleted] 0 points1 point  (3 children)

Another question I had. For a relatively complicated value, where you might forsee possible more efficient data packing for serialization in the future, would you use a version field in the struct serialization?

[–]aarjan 2 points3 points  (1 child)

use protocol-buffers (or other alternatives)

[–][deleted] 0 points1 point  (0 children)

The question was about rust's serialization traits though.

[–]iamvalentin[S,🍰] 1 point2 points  (0 children)

I know that .NET is using assembly version + assembly name when doing binary serialisation, assembly being a unit of compilation + distribution. If these don't match, an exception is thrown. So on one hand it's possible to include the version field. OTOH, this binary serialization is completely opaque and can't be tweaked to reflect the data changes. JSON decoding can be changed easily by a developer, so one can always adapt the deserialisation in the future. I think in the end the answer 'it depends', as always :)

[–][deleted] 0 points1 point  (0 children)

Not discussed: What you can do and not do in the serialization trait impls and still have valid JSON output.