Matches any value that reads as a real number, including an exact _Rational — the widening reader for the numeric tier.
Matches any value that reads as a real number, including an exact _Rational — the widening reader for the numeric tier.
This replaces the synthesized case-class extractor deliberately, and it is the single decision that let the exact tier be added without editing the hundred-odd case _Number(x) sites across the library. The rule it establishes:
case _Number(x) means "reads as the real number x". Code that must preserve exactness matches case r: _Rational explicitly, and must place that case first.
The default is therefore float contagion and exactness is opt-in, which is the safe direction: the worst a missed opt-in can do is degrade a result to the Double behaviour it already had, never produce a wrong one. scalar._Operation is where the opt-in lives, and RationalTest pins the ordering it depends on.
Note this cannot change any existing behaviour: outside the parser's exact mode no _Rational is ever constructed, so the extra arm is unreachable and the Double path stays byte-identical.
Value parameters
e
the expression to read
Attributes
Returns
Some(d) for a _Number or a _Rational, None otherwise