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
As to_writer and to_writer_pretty need a std::fmt::Write as writer it's not possible to give them a std::fs::File directly.
It was possible in 0.8 to do that:
let file = File::create("file.ron").unwrap();to_writer(file,&my_ron);
But it's not possible anymore.
Is there an easy way to write directly to a file? If yes it should be great to have an example in /examples/ as the reader example /examples/decode_file.rs.
The text was updated successfully, but these errors were encountered:
Thank you for raising this issue with the updated API. The decision to move to fmt::Writer was taken because it provides stricter guarantees to users of RON, but I missed your case where you don’t need those guarantees.
At the moment there is no direct way to serialise to io::Write. Whatever we do next, there is the https://crates.io/crates/io-adapters crate that implements this conversion.
We could add additional methods that take io::Write (e.g. to_io_writer) and use an adapter internally. Would that work for you?
I’m thinking that one fun way to write the adapter internally would be to create a Display impl that fmt::Write’s to the fmt::Formatter and to then pass that Display impl into io::Write::write_fmt
As
to_writer
andto_writer_pretty
need astd::fmt::Write
as writer it's not possible to give them astd::fs::File
directly.It was possible in 0.8 to do that:
But it's not possible anymore.
Is there an easy way to write directly to a file? If yes it should be great to have an example in /examples/ as the reader example /examples/decode_file.rs.
The text was updated successfully, but these errors were encountered: