Closed Grinkers closed 10 months ago
With this change, I also removed edn::to_string()
in the last commit. Changing to a ref already is a breaking change to this function and it's needless api surface, doc bloat, etc just to .serialize()
. Now there's an idiomatic and easy way to serialize, chain functions, etc. It's also confusing naming with the trait ToString
which uses the same name.
Rebased in https://github.com/Grinkers/edn-rs/pull/4 and part of #140
This is a breaking change to Serialize and
edn-derive
. See https://github.com/edn-rs/edn-derive/pull/37 for compatibility.Rationale: We want to be able to do things like
It is both annoying and potentially very expensive to move the struct, deallocate, and then create a whole new one each time you may want to serialize. If your Serializable data is inside of another struct, that requires a huge amount of work (making sure things can be
Clone
d, do deep copies, etc just to free it immediately after. In embedded this is probably critical, as you'll need the original, clone, and string data before starting to clean up, so max memory usage will high.As far as performance goes https://github.com/edn-rs/edn-rs/pull/137/files#diff-684ad70dd994bef2eaab407a0147b7b4ec3922c586fa15f9fe015d848abfc963
Take this benchmark with a grain of salt, I'm currently on an old laptop. This shows how expensive move vs borrow is (will continue to scale up depending on size)