You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Encodable/Decodable interface is designed to avoid having to allocate everything to intermediate buffers, but json is encouraging going via String. serialize::json has the top level encode function returning a String, and all the examples use encode directly, there's no demonstration of the good direct-to-Writer API.
If that is deemed too ugly, I think we should work on fixing the ergonomics of the good version, rather than just leaping straight to the -> String ones (e.g. json::encode(&mut io::stdout(), &x) would be nice, and work with json::encode(&mut some_file, &x), json::encode(&mut some_tcp_stream, &x), etc.).
huonw
changed the title
serialize::json is strongly "encouraging" allocating intermediate buffers
serialize::json is encouraging allocating intermediate buffers
Jul 3, 2014
The
Encodable
/Decodable
interface is designed to avoid having to allocate everything to intermediate buffers, butjson
is encouraging going viaString
.serialize::json
has the top levelencode
function returning aString
, and all the examples useencode
directly, there's no demonstration of the good direct-to-Writer
API.That is, something like
can be written a little like
If that is deemed too ugly, I think we should work on fixing the ergonomics of the good version, rather than just leaping straight to the
-> String
ones (e.g.json::encode(&mut io::stdout(), &x)
would be nice, and work withjson::encode(&mut some_file, &x)
,json::encode(&mut some_tcp_stream, &x)
, etc.).cc @aturon
The text was updated successfully, but these errors were encountered: