Skip to main content

parse_typed

Function parse_typed 

Source
fn parse_typed(
    model: &Model,
    declared: ValueType,
    text: &str,
) -> Result<Value, String>
Expand description

Parse cell text as declared, the measure’s declared type. The declared type WINS over the text’s shape: "42" for a Text measure is text, not a number. Unparsable text is an error (never a coerced value), so a bad edit leaves the prior typed cell untouched.

Dates and booleans reuse the formula grammar’s own literal forms (via parser::parse_expr on #...# / TRUE|FALSE), so a date a formula accepts is a date a cell accepts. Numbers use f64::from_str instead: the formula tokenizer reads digits and . only, and a cell must accept -3.5 and 1e9.