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

Support (basic) attributes #435

Open
voidentente opened this issue Jan 20, 2023 · 1 comment
Open

Support (basic) attributes #435

voidentente opened this issue Jan 20, 2023 · 1 comment
Labels
feature A new feature for the syntax or library. help wanted

Comments

@voidentente
Copy link

I think it would be more in line with the Rust style of things if doc comments would be treated as parseable attributes by ron, like in Rust.

Of course, Value would have to be extended into something maybe looking like this:

pub enum Value {
    Bool(Field<bool>),
    Char(Field<char>),
    Map(Field<Map>),
    Number(Field<Number>),
    Option(Field<Option<Box<Value>>>),
    String(Field<String>),
    Seq(Field<Vec<Value>>),
    Unit,
}

pub struct Field<T> {
    attrs: Vec<Attr>
    value: T,
}
@juntyr
Copy link
Member

juntyr commented Jan 23, 2023

I think adding support for doc comments is definitely a neat idea and could help with the question of how to preserve comments across serde - here doc comments would be given a special role in that we would guarantee to keep them around. How this could be achieved for Value and when going through other serde formats would be a bit more difficult and might require some slight hacks such as using special struct names. One more thought that comes to mind is that our Value type is asking more and more to become an AST so that it can express all of RON (almost) losslessly (unfortunately serde’s model is not expressive enough to support fully lossless round trips through RON, Value, and other formats).

@juntyr juntyr added help wanted feature A new feature for the syntax or library. labels Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature for the syntax or library. help wanted
Projects
None yet
Development

No branches or pull requests

2 participants