Skip to main content

gen_trait_fn_body

Function gen_trait_fn_body 

Source
pub(crate) fn gen_trait_fn_body(
    make: &SyntaxFactory,
    func: &Fn,
    trait_path: &Path,
    adt: &Adt,
    trait_ref: Option<TraitRef<'_>>,
) -> Option<BlockExpr>
Expand description

Generate custom trait bodies without default implementation where possible.

If func is defined within an existing impl block, pass TraitRef. Otherwise pass None.

Returns Option so that we can use ? rather than if let Some. Returning None means that generating a custom trait body failed, and the body will remain as todo! instead.