Skip to main content

CompareFn

Type Alias CompareFn 

Source
pub type CompareFn = unsafe fn(a: *const u8, b: *const u8) -> Ordering;
Expand description

compare callback shape: total ordering between two values of the same descriptor. None on the descriptor means the type has no container order.

This is the ordering a container imposes — a heap’s Ord, a sort, the sequence a Map or Set prints and iterates in — and it is total, including over Float NaN (which sorts last and equals itself). The source-level < on a Float keeps IEEE semantics and is a different operation; see ADR-045.

Populated on every type a Map key or Set member can be: Int, Byte, Char, Float, Text, Bool, Unit, Range, and tuples, records and enums recursing through their element types. None on the eleven that can never be one — the nine collections, Closure and VarCell (ADR-138 decision 1). That is deliberately a different set from praxis_hir::capability::supports_ord, which is the source language’s < and sorted(): a tuple has a container order and no <, and (1, 2) < (1, 3) is still Y006 (ADR-138 decision 3).

§Safety

Both pointers must point at values of the descriptor’s type.