Skip to content

Commit 60dc4f8

Browse files
committed
Improve the comment for cs_fold1
1 parent 88a9c69 commit 60dc4f8

File tree

1 file changed

+9
-2
lines changed
  • src/libsyntax_ext/deriving/generic

1 file changed

+9
-2
lines changed

src/libsyntax_ext/deriving/generic/mod.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1745,8 +1745,15 @@ pub fn cs_fold<F>(use_foldl: bool,
17451745
}
17461746
}
17471747

1748-
/// Special version of `cs_fold` that uses the result of a function call on the first field
1749-
/// as the base case when is at least 1 field, and the usual base case when there are zero fields.
1748+
/// Function to fold over fields, with three cases, to generate more efficient and concise code.
1749+
/// When the `substructure` has grouped fields, there are two cases:
1750+
/// Zero fields: call the base case function with None (like the usual base case of `cs_fold`).
1751+
/// One or more fields: call the base case function on the first value (which depends on
1752+
/// `use_fold`), and use that as the base case. Then perform `cs_fold` on the remainder of the
1753+
/// fields.
1754+
/// When the `substructure` is a `EnumNonMatchingCollapsed`, the result of `enum_nonmatch_f`
1755+
/// is returned. Statics may not be folded over.
1756+
/// See `cs_op` in `partial_ord.rs` for a model example.
17501757
pub fn cs_fold1<F, B>(use_foldl: bool,
17511758
f: F,
17521759
mut b: B,

0 commit comments

Comments
 (0)