Skip to content

Commit 9f8c579

Browse files
authored
Merge pull request #2714 from Marcono1234/skipped-field-struct-len
Document that `len` does not include skipped struct fields
2 parents 3f43fca + eae7c2d commit 9f8c579

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

serde/src/ser/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,8 @@ pub trait Serializer: Sized {
11701170
/// then a call to `end`.
11711171
///
11721172
/// The `name` is the name of the struct and the `len` is the number of
1173-
/// data fields that will be serialized.
1173+
/// data fields that will be serialized. `len` does not include fields
1174+
/// which are skipped with [`SerializeStruct::skip_field`].
11741175
///
11751176
/// ```edition2021
11761177
/// use serde::ser::{Serialize, SerializeStruct, Serializer};
@@ -1207,6 +1208,8 @@ pub trait Serializer: Sized {
12071208
/// The `name` is the name of the enum, the `variant_index` is the index of
12081209
/// this variant within the enum, the `variant` is the name of the variant,
12091210
/// and the `len` is the number of data fields that will be serialized.
1211+
/// `len` does not include fields which are skipped with
1212+
/// [`SerializeStructVariant::skip_field`].
12101213
///
12111214
/// ```edition2021
12121215
/// use serde::ser::{Serialize, SerializeStructVariant, Serializer};
@@ -1857,6 +1860,8 @@ pub trait SerializeStruct {
18571860
T: ?Sized + Serialize;
18581861

18591862
/// Indicate that a struct field has been skipped.
1863+
///
1864+
/// The default implementation does nothing.
18601865
#[inline]
18611866
fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error> {
18621867
let _ = key;
@@ -1919,6 +1924,8 @@ pub trait SerializeStructVariant {
19191924
T: ?Sized + Serialize;
19201925

19211926
/// Indicate that a struct variant field has been skipped.
1927+
///
1928+
/// The default implementation does nothing.
19221929
#[inline]
19231930
fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error> {
19241931
let _ = key;

0 commit comments

Comments
 (0)