Skip to main content

collect

Function collect 

Source
fn collect<F: Debug, P>(
    enum_name: &str,
    names: impl Iterator<Item = &'static str>,
    construct: fn(&str) -> Option<F>,
    natural_inputs: fn(&F) -> Option<Vec<SqlColumnType>>,
    samples: Vec<Sample<F>>,
    variant_name: fn(&F) -> &'static str,
    properties: fn(&Sample<F>) -> P,
) -> BTreeMap<String, P>
Expand description

Records the properties of every variant of one function enum, keyed as described on Sample.

A variant’s primary record comes from its unlabeled hand-written sample if there is one, otherwise from a payload-free instance built by construct (see from_variant_name on the enums), probed at the column types natural_inputs reports for it, if any. Hand-written primaries take precedence so a constructible variant can still be probed at chosen input types.

A variant whose payload has fields must have at least one hand-written sample, even when the payload is constructible with every field defaulted, because a defaulted payload sees only one branch of any property that depends on it.

Panics if a variant has no primary or no required sample, if two samples share a name and label, or if probing a sample panics, in which case the panic names the sample.