-
Notifications
You must be signed in to change notification settings - Fork 60
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
Add macros to ease the creation of structures #192
Comments
I'm not a fan, TBH. Macros are a different, library-specific language, are not discoverable (you need to read the docs or the implementation instead of relying on auto-complete), and can interact poorly with IDEs. They're fine as an alternative, but I wouldn't want todl deprecate the current approach. |
And no plans to deprecate the public fields in the structs, if users want to create them that way. |
I can understand this criticism of macros in general. I think it's less problematic here, because I'm hoping that the "library specific language" we use in this case is geojson. I'm not sure if it's viable, but I was envisioning something like the // The type of `john` is `serde_json::Value`
let john = json!({
"name": "John Doe",
"age": 43,
"phones": [
"+44 1234567",
"+44 2345678"
]
}); Yes that macro is using a DSL - but the DSL is JSON. I think it's pretty reasonable for people generating JSON to understand how to read/write JSON. So I'm imagining something like that, but it would be more restrictive than I too am in favor of keeping the idiomatic verbose rust way of building all these structures for those that prefer it. Presumably any DSL would ultimately be built on top of those things anyway. |
(copied from discord)
what do people think about adding macros in the geojson crate to ease creation?
versus
not the exact syntax necessarily. just think it would be great to have an easier way to construct the structures
it'd be really slick if the body of the macro was identical syntax to geojson
The text was updated successfully, but these errors were encountered: