Skip to main content

prepare_compound_cell_formatter

Function prepare_compound_cell_formatter 

Source
pub fn prepare_compound_cell_formatter(
    sheet: &Sheet,
    id: CellId,
) -> Result<impl Fn(&Sheet) -> Result<String> + use<>>
Expand description

Prepares canonical compound-cell formatting from the cell owner’s debug capability.

The returned closure reads the current value, checks its complete shape, and formats through the retained capability. It does not consume or clone values.

§Errors

Rejects an unknown cell, noncompound storage, or unavailable debug capability. The closure also rejects a different shape or missing cell in its input sheet.

  • Complexity: Preparation O(1); each call O(n + v + s) for n type nodes, v contained values and s output bytes, excluding leaf formatter costs.

§Examples

let parsed = adam_lang::AdamParser::new(adam_lang::TypeRegistry::new(), cel_parser::OpLookup::new())
    .parse_str("sheet s { cell xs: [i32]; }").unwrap();
let format = adam_lang::prepare_compound_cell_formatter(&parsed, parsed.cell_names["xs"].0).unwrap();
assert_eq!(format(&parsed).unwrap(), "[]");