From 19185a827b346bc9c9762a87ad8859ea78d9bf66 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 5 Sep 2023 10:43:15 -0500 Subject: [PATCH 1/2] Help untagged users discover expecting --- _src/container-attrs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_src/container-attrs.md b/_src/container-attrs.md index fa5b0bc..f6d216f 100644 --- a/_src/container-attrs.md +++ b/_src/container-attrs.md @@ -70,6 +70,8 @@ Use the untagged enum representation for this enum. See [enum representations] for details on this representation. + When no variant matches, the error may be uninformative which can be improved with [`serde(expecting)`](#expecting). + - ##### `#[serde(bound = "T: MyTrait")]` {#bound} Where-clause for the `Serialize` and `Deserialize` impls. This replaces any From 65898878b1936cd2f637a3338386c31a097ede91 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 5 Sep 2023 10:43:32 -0500 Subject: [PATCH 2/2] Help untagged users know of performance issues and fix them Inspired by serde-rs/serde#2101 --- _src/container-attrs.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/_src/container-attrs.md b/_src/container-attrs.md index f6d216f..5090dc6 100644 --- a/_src/container-attrs.md +++ b/_src/container-attrs.md @@ -72,6 +72,11 @@ When no variant matches, the error may be uninformative which can be improved with [`serde(expecting)`](#expecting). + In performance-critical code, checking each variant and processing the errors can be slow. + In these cases, it may be better to hand-implement the deserialize trait for which [serde-untagged] may help. + + [serde-untagged]: https://docs.rs/serde-untagged + - ##### `#[serde(bound = "T: MyTrait")]` {#bound} Where-clause for the `Serialize` and `Deserialize` impls. This replaces any