Skip to content

Commit c302ef8

Browse files
committed
Merge pull request 120 from jonasbb/flatten-deny-unknown-fields
2 parents 33a897a + af0e2e6 commit c302ef8

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

_src/attr-flatten.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ The `flatten` attribute inlines keys from a field into the parent struct.
55
supported only within structs that have named fields, and the field to which it
66
is applied must be a struct or map type.
77

8+
*Note:* `flatten` is not supported in combination with structs that use
9+
[`deny_unknown_fields`]. Neither the outer nor inner flattened struct should use
10+
that attribute.
11+
12+
[`deny_unknown_fields`]: container-attrs.md#deny_unknown_fields
13+
814
The `flatten` attribute serves the following two common use cases:
915

1016
### Factor out frequently grouped keys

_src/container-attrs.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
this attribute is not present, by default unknown fields are ignored for
3131
self-describing formats like JSON.
3232

33+
*Note:* this attribute is not supported in combination with [`flatten`],
34+
neither on the outer struct nor on the flattened field.
35+
36+
[`flatten`]: field-attrs.md#flatten
37+
3338
- ##### `#[serde(tag = "type")]` {#tag}
3439

3540
Use the internally tagged enum representation for this enum, with the given

_src/field-attrs.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
with arbitrary string keys. The [struct flattening](attr-flatten.md) page
3939
provides some examples.
4040

41+
*Note:* this attribute is not supported in combination with structs that use
42+
[`deny_unknown_fields`]. Neither the outer nor inner flattened struct should
43+
use that attribute.
44+
45+
[`deny_unknown_fields`]: container-attrs.md#deny_unknown_fields
46+
4147
- ##### `#[serde(skip)]` {#skip}
4248

4349
Skip this field: do not serialize or deserialize it.

0 commit comments

Comments
 (0)