File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ The `flatten` attribute inlines keys from a field into the parent struct.
5
5
supported only within structs that have named fields, and the field to which it
6
6
is applied must be a struct or map type.
7
7
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
+
8
14
The ` flatten ` attribute serves the following two common use cases:
9
15
10
16
### Factor out frequently grouped keys
Original file line number Diff line number Diff line change 30
30
this attribute is not present, by default unknown fields are ignored for
31
31
self-describing formats like JSON.
32
32
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
+
33
38
- ##### ` #[serde(tag = "type")] ` {#tag}
34
39
35
40
Use the internally tagged enum representation for this enum, with the given
Original file line number Diff line number Diff line change 38
38
with arbitrary string keys. The [ struct flattening] ( attr-flatten.md ) page
39
39
provides some examples.
40
40
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
+
41
47
- ##### ` #[serde(skip)] ` {#skip}
42
48
43
49
Skip this field: do not serialize or deserialize it.
You can’t perform that action at this time.
0 commit comments