ron-rs/ron

Would it be possible to make ron 100% Rust-syntax compatible?

Opened this issue · 1 comments

Maybe this is out of scope for this project, but would it be possible to make the ron format parseable by the Rust compiler? This would resemble how JSON is a 100% valid subset of JavaScript.

This might have interesting applications for code generation, especially in build.rs.

That's an interesting question for sure. I am hoping to slowly make ron more Rusty (e.g. #438), but there are some design decisions that differ.

Rust code always needs to be verbose in all types, whereas ron is designed to also be compact when all types are known (e.g. by optionally omitting struct names). Therefore, I don't think that every valid ron document will always be valid Rust, but that perhaps in the future there could be a combination of pretty serialisation flags which outputs a Rust-compatible subset of ron.

  • How to deal with ron's vectors, since [ 42 ] is an array, not a Vec?
  • How to deal with ron's maps, since maps like { "a": 42 } do not have language support in Rust?

I think that the most likely avenue could be some small translation layer that takes in a best-effort-Rusty ron string and makes some final tweaks to it.