Skip to content

Every integer width implements Eq, Ord and Default: i8, i16, u16, u32 and u64 had none - #3610

Merged
ehartford merged 1 commit into
mainfrom
std-int-traits
Nov 25, 2026
Merged

ehartford merged 1 commit into
mainfrom
std-int-traits

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Found while planning the numeric methods of #3483 (part of #3483).

A generic function bounded by Ord, Eq or Default was refused for five of the twelve integer types:

fn larger[T: Ord](a: T, b: T) -> T: if a.cmp(&b) > 0: a else: b
larger(3 as u64, 9)     // type 'u64' does not implement trait 'Ord' required by bound 'T: Ord'

lib/std/traits.with implemented the three traits for i32, i64, i128, isize, u8, u128 and usize only. The fifteen missing impls are added, each the same line as its neighbours. f32 and f64 stay without Eq and Ord on purpose (TotalF32 / TotalF64 are the ordered forms).

Test: behav_std_int_traits_every_width; it fails on main.

Evidence at cd28420: release build; :unit-return-review, :ceremony-census, :self-audit, :behavior-tests green; battery green. Standard-library declarations only, nothing platform-specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant