XU XUv0.8.8
中文

API

#cmp

import: #cmp

counts: 9 fns, 0 methods, 0 types, 0 consts, 1 ifaces

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

less fn 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

self Self
receiver Self (value receiver)
other Self
the other value of the same type (Self)

Returns

bool — true or false

less_string

XuAPI
pub fn 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

a string
left operand (string)
b string
right operand (string)

Returns

bool — true or false

less_int

XuAPI
pub fn 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

a int
left operand (int)
b int
right operand (int)

Returns

bool — true or false

compare_int

XuAPI
pub fn compare_int(a int, b int) int

Purpose

Compare int.

Parameters

a int
left operand (int)
b int
right operand (int)

Returns

int — -1 if less, 0 if equal, 1 if greater

less_f64

XuAPI
pub fn less_f64(a f64, b f64) bool

Purpose

Less f64.

Parameters

a f64
left operand (f64)
b f64
right operand (f64)

Returns

bool — true or false

compare_f64

XuAPI
pub fn compare_f64(a f64, b f64) int

Purpose

Compare f64.

Parameters

a f64
left operand (f64)
b f64
right operand (f64)

Returns

int — -1 if less, 0 if equal, 1 if greater

or_int

XuAPI
pub fn or_int(a int, b int) int

Purpose

1.22 `cmp.Or` as two-arg pairs (no generic comparable / variadic).

Parameters

a int
value (int)
b int
b (int)

Returns

int — a value of this type

or_string

XuAPI
pub fn or_string(a &string, b &string) string

Purpose

Or string.

Parameters

a &string
value (borrowed; caller keeps it; type &string)
b &string
b (borrowed; caller keeps it; type &string)

Returns

string — result string

or_f64

XuAPI
pub fn or_f64(a f64, b f64) f64

Purpose

Or f64.

Parameters

a f64
value (f64)
b f64
b (f64)

Returns

f64 — a value of this type

compare_string

XuAPI
pub fn compare_string(a string, b string) int

Purpose

Compare string.

Parameters

a string
left operand (string)
b string
right operand (string)

Returns

int — -1 if less, 0 if equal, 1 if greater