Skip to main content

compare_values

Function compare_values 

Source
pub fn compare_values(a: &VmValue, b: &VmValue) -> i32
Expand description

Total-order comparison used for sorting, min/max, and similar reductions.

IEEE-754 NaN is unordered, so try_compare_values returns None for it; here we fall back to 0 (treat as equal) so a stray NaN does not destabilize a sort. Relational operators (<, >, <=, >=) must NOT use this fallback — they go through try_compare_values so that any comparison with NaN yields false, as the language spec and IEEE-754 require.