Comparison: struct@ Ord and less_*/compare_*. f64: NaN is less than non-NaN; NaN equals NaN.
struct@ Ord
XuAPI
struct@ Ord {
fn less(Self) bool
}
Purpose
Ordered comparison surface. Constraint name is a single ident, so Ord lives here and `sort.slice` constrains `T: Ord` across modules. `Self` in method signatures means the concrete implementing type.
Parameters
lessfn less(Self) bool
Method on `Ord`: whether this value is strictly less than the other.
(Ord) less
XuAPI
fn less(Self) bool
Purpose
Method on `Ord`: whether this value is strictly less than the other.
Parameters
selfSelf
receiver Self (value receiver)
otherSelf
the other value of the same type (Self)
Returns
bool — true or false
less_string
XuAPI
pubfn less_string(a string, b string) bool
Purpose
Lexicographic string compare (same rules as former sort.str_less). Used when builtin `string.less` is lowered; also callable directly.
Parameters
astring
left operand (string)
bstring
right operand (string)
Returns
bool — true or false
less_int
XuAPI
pubfn less_int(a int, b int) bool
Purpose
1.21 cmp.Less / Compare as paired functions (no generic Ordered). 1.22 cmp.Or as two-arg or_int / or_string (string args borrowed).
Parameters
aint
left operand (int)
bint
right operand (int)
Returns
bool — true or false
compare_int
XuAPI
pubfn compare_int(a int, b int) int
Purpose
Compare int.
Parameters
aint
left operand (int)
bint
right operand (int)
Returns
int — -1 if less, 0 if equal, 1 if greater
less_f64
XuAPI
pubfn less_f64(a f64, b f64) bool
Purpose
Less f64.
Parameters
af64
left operand (f64)
bf64
right operand (f64)
Returns
bool — true or false
compare_f64
XuAPI
pubfn compare_f64(a f64, b f64) int
Purpose
Compare f64.
Parameters
af64
left operand (f64)
bf64
right operand (f64)
Returns
int — -1 if less, 0 if equal, 1 if greater
or_int
XuAPI
pubfn or_int(a int, b int) int
Purpose
1.22 `cmp.Or` as two-arg pairs (no generic comparable / variadic).