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

Use skip_serializing_none macro to reduce clutter in helix-dap #7627

Conversation

thomasaarholt
Copy link
Contributor

New rust developer here, please be gentle.

I decided to take a look at #6265 to see if there was anything I could help with, and noticed that there were about 200 lines of #[serde(skip_serializing_if = "Option::is_none")] that could be removed using the #[skip_serializing_none] macro. It's now a lot easier to parse it, at least to my eyes.

I wasn't sure whether to add cargo.lock or not, so I added it in a separate commit.

Copy link
Member

@pascalkuthe pascalkuthe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a functional perspective, this seems fine. However, we usually don't want to add new dependencies if it can be avoided. Both to avoid additional compile time hits and to reduce the need to maintain and audit them. There is of course no hard rule but generally the rule of thumb is: If a dependency just saves us writing a couple lines of trivial code its not worth it.

I think both for DAP we never actually want to send None values so one way to solve this without requiring additional proc macros/dependencies would be to simply write our own serializer to wraps the serde_json serializer and always ignore None values. So that could be way to reduce the noise here and avoid accidently forgetting there annotations.

@thomasaarholt
Copy link
Contributor Author

I understand, that makes sense. I’m not sure I can commit to that sort of thing right now, but I will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants