Function rustc_builtin_macros::deriving::generic::cs_fold1[][src]

pub fn cs_fold1<F, B>(
    use_foldl: bool,
    f: F,
    b: B,
    enum_nonmatch_f: Box<dyn FnMut(&mut ExtCtxt<'_>, Span, (&[Ident], &[Ident]), &[P<Expr>]) -> P<Expr> + '_>,
    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>, 
Expand description

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 an 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.