sway_ir::metadata

Function combine

Source
pub fn combine(
    context: &mut Context<'_>,
    md_idx_a: &Option<MetadataIndex>,
    md_idx_b: &Option<MetadataIndex>,
) -> Option<MetadataIndex>
Expand description

Combine two metadata indices into one.

When multiple indices are attached to an IR value or function they must go in a list. It is rare for MetadataIndex to exist outside of an Option though, so we may want to combine two optional indices when we might end up with only one or the other, or maybe even None.

This function conveniently has all the logic to return the simplest combination of two Option<MetadataIndex>s.