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

Improve confusing wording in tag container attribute's description #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JohnDowson
Copy link

Serializing a structure like this

#[derive(Serialize, Deserialize)]
#[serde(tag = "kind"]
enum Foo {
    Bar(Bar),
}

#[derive(Serialize, Deserialize)]
#[serde(tag = "kind")]
struct Bar {
    baz: String
}

results in duplicated kind fields, which is consistent with the struct being tagged externally, rather than the described behaviour of

Serialize the struct's name (or value of serde(rename)) as a field with the given key, in front of all the real fields of the struct.
which suggests that the tag would be prepended to the struct's fields.

@dtolnay
Copy link
Member

dtolnay commented Sep 18, 2024

The original text is better, in my opinion. "External" in the context of a tag attribute suggests "externally tagged", which means a specific thing and is not the representation that #[serde(tag = "kind")] struct Bar {…} uses.

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

Successfully merging this pull request may close these issues.

2 participants