Skip to main content

Module number

Module number 

Source
Expand description

Number text (RULES.md §12): a provider’s number reaches the reply with the provider’s own spelling.

A runner that decodes a number into binary floating point and encodes it again can change its spelling (0.10 becomes 0.1, 1E+30 becomes 1e30) and, past 17 significant digits, its value. Callers threshold on these numbers, so a role keeps the text: each known numeric member is a NumberText, serde_json’s RawValue, which holds the exact bytes the provider sent.

The serde_json features arbitrary_precision and float_roundtrip would also keep spellings, but they change number parsing for every crate in a workspace build. No role crate enables them.

Functions§

is_number_literal
Whether text is one JSON number literal: an optional -, an integer part without leading zeros, an optional fraction and an optional exponent, with no surrounding whitespace.
is_number_text
Whether raw holds one JSON number.
number_text
text as number text, or why it is not one JSON number literal.
number_text_of
number as number text, in serde_json’s spelling of it. For building a value a runner computed itself; a provider’s number is kept as it came.
same_text
Whether two optional raw values hold the same text.

Type Aliases§

NumberText
A JSON value kept as the exact text it arrived as.