Function syntax_ext::deriving::generic::cs_fold1 [−][src]
pub fn cs_fold1<F, B>(
use_foldl: bool,
f: F,
b: B,
enum_nonmatch_f: EnumNonMatchCollapsedFunc,
cx: &mut ExtCtxt,
trait_span: Span,
substructure: &Substructure
) -> P<Expr> where
F: FnMut(&mut ExtCtxt, Span, P<Expr>, P<Expr>, &[P<Expr>]) -> P<Expr>,
B: FnMut(&mut ExtCtxt, Option<(Span, P<Expr>, &[P<Expr>])>) -> P<Expr>,
🔬 This is a nightly-only experimental API. (rustc_private
)
this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml
instead?
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.