Skip to content

Commit a661bd1

Browse files
committed
Help untagged users know of performance issues and fix them
Inspired by serde-rs/serde#2101
1 parent 97cf40a commit a661bd1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

_src/container-attrs.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858

5959
When no variant matches, the error may be uninformative which can be improved with [`serde(expecting)`](#expecting).
6060

61+
In performance-critical code, checking each variant and processing the errors can be slow.
62+
In these cases, it may be better to hand-implement the deserialize trait for which [serde-untagged] may help.
63+
6164
- ##### `#[serde(bound = "T: MyTrait")]` {#bound}
6265

6366
Where-clause for the `Serialize` and `Deserialize` impls. This replaces any
@@ -122,3 +125,5 @@
122125
Specify a custom type expectation text for deserialization error messages.
123126
This is used by the generated `expecting` method for the container `Visitor`,
124127
and as a fallthrough error message for untagged enums.
128+
129+
[serde-untagged]: https://docs.rs/serde-untagged

0 commit comments

Comments
 (0)