Skip to content

Commit

Permalink
Document expecting container attribute
Browse files Browse the repository at this point in the history
This attribute has flew under the radar of serde documentation since it
was introduced by serde-rs/serde#1916. Given how
useful it can be to improve untagged enum deserialization error messages
and that its introduction has been uncontroversial so far, I think it's
a good idea to document it.
  • Loading branch information
AlexTMjugador committed Aug 5, 2023
1 parent b33520f commit 12bb7d4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions _src/container-attrs.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,9 @@
Specify a path to the `serde` crate instance to use when referring to Serde
APIs from generated code. This is normally only applicable when invoking
re-exported Serde derives from a public macro in a different crate.

- ##### `#[serde(expecting = "...")]` {#expecting}

Specify a custom type expectation text for deserialization error messages.
This is used by the generated `expecting` method for the container `Visitor`,
and as a fallthrough error message for untagged enums.

0 comments on commit 12bb7d4

Please sign in to comment.