about summary refs log tree commit diff
path: root/src/libsyntax_ext
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-04-12 01:33:52 +0100
committervarkor <github@varkor.com>2018-04-12 01:33:52 +0100
commit60dc4f8ec8729bd851b8ee8e3dac9abae1f62bef (patch)
tree796e60a55083aefab1931c169532f6f9bdd089d1 /src/libsyntax_ext
parent88a9c691212996b9dd8921c597182b137bb1771a (diff)
downloadrust-60dc4f8ec8729bd851b8ee8e3dac9abae1f62bef.tar.gz
rust-60dc4f8ec8729bd851b8ee8e3dac9abae1f62bef.zip
Improve the comment for cs_fold1
Diffstat (limited to 'src/libsyntax_ext')
-rw-r--r--src/libsyntax_ext/deriving/generic/mod.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs
index 11bd72691c5..82ed6a29b77 100644
--- a/src/libsyntax_ext/deriving/generic/mod.rs
+++ b/src/libsyntax_ext/deriving/generic/mod.rs
@@ -1745,8 +1745,15 @@ pub fn cs_fold<F>(use_foldl: bool,
     }
 }
 
-/// Special version of `cs_fold` that uses the result of a function call on the first field
-/// as the base case when is at least 1 field, and the usual base case when there are zero fields.
+/// Function to fold over fields, with three cases, to generate more efficient and concise code.
+/// When the `substructure` has grouped fields, there are two cases:
+/// Zero fields: call the base case function with None (like the usual base case of `cs_fold`).
+/// One or more fields: call the base case function on the first value (which depends on
+/// `use_fold`), and use that as the base case. Then perform `cs_fold` on the remainder of the
+/// fields.
+/// When the `substructure` is a `EnumNonMatchingCollapsed`, the result of `enum_nonmatch_f`
+/// is returned. Statics may not be folded over.
+/// See `cs_op` in `partial_ord.rs` for a model example.
 pub fn cs_fold1<F, B>(use_foldl: bool,
                       f: F,
                       mut b: B,