Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
surban opened this issue Sep 8, 2023 · 1 comment
Open

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

surban opened this issue Sep 8, 2023 · 1 comment
Labels
enhancement feature A new feature for the syntax or library. question

Comments

@surban
Copy link

surban commented Sep 8, 2023

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.

@juntyr juntyr added enhancement question feature A new feature for the syntax or library. labels Sep 9, 2023
@juntyr
Copy link
Member

juntyr commented Sep 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature A new feature for the syntax or library. question
Projects
None yet
Development

No branches or pull requests

2 participants