Skip to main content

check_struct_default_fn

Function check_struct_default_fn 

Source
pub fn check_struct_default_fn(
    func: &Function,
    struct_id: u16,
    returns: Option<(&DataType, Span)>,
    sources: &[Source],
    types: TypeNames<'_>,
)
Expand description

Checks the default function an impl block on struct struct_id declares.

Every path that builds the struct’s default calls it with nothing and takes the struct from what it hands back, so it declares no parameters and returns the struct.

returns is the type it hands back and the span that says so, when that is known: the -> Type annotation where the function is declared, or what its body returns once a default is built from it.