Skip to main content

can_generate_default_impl

Function can_generate_default_impl 

Source
pub fn can_generate_default_impl(
    typ: &TypeDef,
    known_default_types: &HashSet<&str>,
) -> bool
Expand description

Check if a type’s fields can all be safely defaulted. Primitives, strings, collections, Options, and Duration all have Default impls. Named types (custom structs) only have Default if explicitly marked with has_default=true. If any field is a Named type without has_default, returning true would generate code that calls Default::default() on a type that doesn’t implement it.