logos.lang.cmp

Module lang · package logos-lang

Traits

traitEq

trait Eq

Defines total equality via eq, with ne derived by default. Not implemented for floats — NaN != NaN breaks totality; see PartialEq instead.

Implemented by: i32 i64 u32 u64 u8 i8 u16 i16 bool usize isize char str $tuple$variadic Option Result TypeId NonZero String

traitOrd

trait Ord

Trait for types that form a total order. Float types are intentionally excluded: NaN breaks totality.

Implemented by: i8 i16 i32 i64 $ref_&i32 $ref_&i64 u8 u16 u32 u64 usize isize bool str

traitPartialEq

trait PartialEq

Defines partial equality via eq, with ne derived by default. Unlike Eq, does not require totality — implemented for floats where NaN != NaN.

Implemented by: f32 f64

traitPartialOrd

trait PartialOrd

Marker trait for partial ordering — currently empty pending a partial_cmp method shape.

Types

enumOrdering

enum Ordering

The result of a total-order comparison between two values.

Implements: Display Debug

Variants

Equal
Greater
Less

Methods

fn is_eq(self: Ordering) -> bool

Returns true if the ordering is Equal.

fn is_ge(self: Ordering) -> bool

Returns true if the ordering is Greater or Equal.

fn is_gt(self: Ordering) -> bool

Returns true if the ordering is Greater.

fn is_le(self: Ordering) -> bool

Returns true if the ordering is Less or Equal.

fn is_lt(self: Ordering) -> bool

Returns true if the ordering is Less.

fn is_ne(self: Ordering) -> bool

Returns true if the ordering is not Equal.

fn reverse(self: Ordering) -> Ordering

Returns the reversed ordering: Less <-> Greater, Equal unchanged.

fn then(self: Ordering, other: Ordering) -> Ordering

Returns other if self is Equal, else self; chains lexicographic comparisons.

fn then_with(self: Ordering, f: fn() -> Ordering) -> Ordering

Returns f() if self is Equal, else self; lazy variant of then.

Functions

fncmp_max_by

fn cmp_max_by(a: T, b: T, compare: fn(T, T) -> Ordering) -> T

Returns the larger of a and b per compare; b when they compare equal.

fncmp_max_by_key

fn cmp_max_by_key(a: T, b: T, key: fn(T) -> K) -> T

Returns the argument whose key projection is larger; b when the keys compare equal.

fncmp_min_by

fn cmp_min_by(a: T, b: T, compare: fn(T, T) -> Ordering) -> T

Returns the smaller of a and b per compare; a when they compare equal.

fncmp_min_by_key

fn cmp_min_by_key(a: T, b: T, key: fn(T) -> K) -> T

Returns the argument whose key projection is smaller; a when the keys compare equal.

fncmp_opt_is_ge

fn cmp_opt_is_ge(o: Option) -> bool

Returns true if o is Some(Greater) or Some(Equal); None yields false.

fncmp_opt_is_gt

fn cmp_opt_is_gt(o: Option) -> bool

Returns true if o is Some(Greater); None yields false.

fncmp_opt_is_le

fn cmp_opt_is_le(o: Option) -> bool

Returns true if o is Some(Less) or Some(Equal); None yields false.

fncmp_opt_is_lt

fn cmp_opt_is_lt(o: Option) -> bool

Returns true if o is Some(Less); None (incomparable) yields false.