Skip to main content

emit_struct_init

Function emit_struct_init 

Source
fn emit_struct_init(
    out: &mut String,
    ptr_field: &FieldDef,
    struct_def: &StructDef,
    builder_var: &str,
    param_name: &str,
    indent: &str,
    schema: &ParsedSchema,
    counter: &mut u32,
)
Expand description

Emit code to init a sub-struct and set its non-union fields.

For optional fields (field.optional = true), adds ?? defaultValue coalescing so TypeScript strict mode doesn’t reject T | undefined where T is expected.