Skip to main content

emit_option_setter

Function emit_option_setter 

Source
fn emit_option_setter(
    out: &mut String,
    field: &FieldDef,
    opt_struct: &StructDef,
    inner_type_name: &str,
    builder_var: &str,
    value_expr: &str,
    indent: &str,
)
Expand description

Emit code to write an Option* wrapper struct at a pointer slot.

Generates: if value !== undefined, init the option struct and set the discriminant + inner value. Else: leave the pointer null (cap’n proto default = none).