Respect Serde's skip attribute #617
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Currently, annotating a variant or field with the
#[serde(skip)]
,#[serde(skip_serializing)]
,#[serde(skip_serializing_if = "path")]
, or#[serde(skip_deserializing)]
attributes results in successful compilation but causes runtime errors. Ignoring some fields or variants can be useful when exposing partially private data from the business logic in Rust to Dart.This PR adds support for the
#[serde(skip)]
attribute and handles the#[serde(skip_serializing)]
,#[serde(skip_serializing_if = "path")]
and#[serde(skip_deserializing)]
attributes by throwing compile-time errors. It also adds a section to the documentation about ignoring fields or variants and adds a few cases to the tests.Handling only the
#[serde(skip)]
attribute was a deliberate choice because it enables all the functionality of a skip attribute for this project. Supporting the other attributes quickly leads to implementation complexity and user confusion.For more information on these attributes, see https://serde.rs/variant-attrs.html and https://serde.rs/field-attrs.html.
Before Committing
Please make sure that you've analyzed and formatted the files.