multitype/int/
mod.rs

1// Copyright 2025 Gabriel Bjørnager Jensen.
2
3mod test;
4
5mod r#impl;
6
7use crate::{
8	Array,
9	Uint,
10};
11use crate::compat::{
12	CloneToUninit,
13	ConstParamTy_,
14	Freeze,
15	NumBufferTrait,
16	Step,
17	StructuralPartialEq,
18	Thin,
19	ToOwned,
20	ToString,
21	TrustedStep,
22	UseCloned,
23};
24
25use core::any::Any;
26use core::convert::Infallible;
27use core::fmt::{
28	Binary,
29	Debug,
30	Display,
31	LowerExp,
32	LowerHex,
33	Octal,
34	UpperExp,
35	UpperHex,
36};
37use core::hash::Hash;
38use core::iter::{Product, Sum};
39use core::num::ParseIntError;
40use core::ops::{
41	Add,
42	AddAssign,
43	BitAnd,
44	BitAndAssign,
45	BitOr,
46	BitOrAssign,
47	BitXor,
48	BitXorAssign,
49	Div,
50	DivAssign,
51	Mul,
52	MulAssign,
53	Neg,
54	Not,
55	Rem,
56	RemAssign,
57	Shl,
58	ShlAssign,
59	Shr,
60	ShrAssign,
61	Sub,
62	SubAssign,
63};
64use core::panic::{RefUnwindSafe, UnwindSafe};
65use core::str::FromStr;
66
67/// A generic, signed integer.
68///
69/// This trait abstracts the interfaces defined by [`i8`], [`i16`], [`i32`], [`i64`], [`i128`], and [`isize`] so that these may be used as a single type.
70///
71/// See also [`IntLeast16`](crate::IntLeast16), [`IntLeast32`](crate::IntLeast32), and [`IntLeast64`](crate::IntLeast64).
72///
73/// # Safety
74///
75/// [`Uint`](Self::Uint) must be *the* unsigned counterpart to `Self` so that transmutations between the two are always valid.
76///
77/// Furthermore, all items must behave exactly as their standard counterparts.
78pub unsafe trait Int
79where
80	Self:
81		crate::seal::Int
82		+ 'static
83		+ Any
84		+ Binary
85		+ CloneToUninit
86		+ ConstParamTy_
87		+ Copy
88		+ Debug
89		+ Default
90		+ Display
91		+ Eq
92		+ Freeze
93		+ From<bool>
94		+ From<i8>
95		+ FromStr
96		+ Hash
97		+ LowerExp
98		+ LowerHex
99		+ NumBufferTrait
100		+ Octal
101		+ Ord
102		+ PartialEq
103		+ PartialOrd
104		+ Product
105		+ RefUnwindSafe
106		+ Send
107		+ Step
108		+ StructuralPartialEq
109		+ Sum
110		+ Sync
111		+ Thin
112		+ ToOwned
113		+ ToString
114		+ TrustedStep
115		+ TryFrom<bool, Error = Infallible>
116		+ TryFrom<i128>
117		+ TryFrom<i16>
118		+ TryFrom<i32>
119		+ TryFrom<i64>
120		+ TryFrom<i8,   Error = Infallible>
121		+ TryFrom<isize>
122		+ TryFrom<u128>
123		+ TryFrom<u16>
124		+ TryFrom<u32>
125		+ TryFrom<u64>
126		+ TryFrom<u8>
127		+ TryFrom<usize>
128		+ TryInto<i128>
129		+ TryInto<i16>
130		+ TryInto<i32>
131		+ TryInto<i64>
132		+ TryInto<i8>
133		+ TryInto<isize>
134		+ TryInto<u128>
135		+ TryInto<u16>
136		+ TryInto<u32>
137		+ TryInto<u64>
138		+ TryInto<u8>
139		+ TryInto<usize>
140		+ Unpin
141		+ UnwindSafe
142		+ UpperExp
143		+ UpperHex
144		+ UseCloned
145		// Arithmetic operators:
146		+ Add<          Output = Self>
147		+ BitAnd<       Output = Self>
148		+ BitOr<        Output = Self>
149		+ BitXor<       Output = Self>
150		+ Div<          Output = Self>
151		+ Mul<          Output = Self>
152		+ Neg<          Output = Self>
153		+ Not<          Output = Self>
154		+ Rem<          Output = Self>
155		+ Shl<          Output = Self>
156		+ Shl<   u8,    Output = Self>
157		+ Shl<   u16,   Output = Self>
158		+ Shl<   u32,   Output = Self>
159		+ Shl<   u64,   Output = Self>
160		+ Shl<   u128,  Output = Self>
161		+ Shl<   usize, Output = Self>
162		+ Shl<   i8,    Output = Self>
163		+ Shl<   i16,   Output = Self>
164		+ Shl<   i32,   Output = Self>
165		+ Shl<   i64,   Output = Self>
166		+ Shl<   i128,  Output = Self>
167		+ Shl<   isize, Output = Self>
168		+ Shr<          Output = Self>
169		+ Shr<   u8,    Output = Self>
170		+ Shr<   u16,   Output = Self>
171		+ Shr<   u32,   Output = Self>
172		+ Shr<   u64,   Output = Self>
173		+ Shr<   u128,  Output = Self>
174		+ Shr<   usize, Output = Self>
175		+ Shr<   i8,    Output = Self>
176		+ Shr<   i16,   Output = Self>
177		+ Shr<   i32,   Output = Self>
178		+ Shr<   i64,   Output = Self>
179		+ Shr<   i128,  Output = Self>
180		+ Shr<   isize, Output = Self>
181		+ Sub<          Output = Self>
182		// Assigning arithmetic operators:
183		+ AddAssign
184		+ BitAndAssign
185		+ BitOrAssign
186		+ BitXorAssign
187		+ DivAssign
188		+ MulAssign
189		+ RemAssign
190		+ ShlAssign
191		+ ShlAssign<u8>
192		+ ShlAssign<u16>
193		+ ShlAssign<u32>
194		+ ShlAssign<u64>
195		+ ShlAssign<u128>
196		+ ShlAssign<usize>
197		+ ShlAssign<i8>
198		+ ShlAssign<i16>
199		+ ShlAssign<i32>
200		+ ShlAssign<i64>
201		+ ShlAssign<i128>
202		+ ShlAssign<isize>
203		+ ShrAssign
204		+ ShrAssign<u8>
205		+ ShrAssign<u16>
206		+ ShrAssign<u32>
207		+ ShrAssign<u64>
208		+ ShrAssign<u128>
209		+ ShrAssign<usize>
210		+ ShrAssign<i8>
211		+ ShrAssign<i16>
212		+ ShrAssign<i32>
213		+ ShrAssign<i64>
214		+ ShrAssign<i128>
215		+ ShrAssign<isize>
216		+ SubAssign,
217{
218	/// The equivalent, unsigned, integral type.
219	type Uint: Uint<
220		Int   = Self,
221		Bytes = Self::Bytes,
222	>;
223
224	/// The array type that represents the bytes of this type.
225	type Bytes:
226		Array<Scalar = u8>
227		+ 'static
228		+ Any
229		+ CloneToUninit
230		+ ConstParamTy_
231		+ Copy
232		+ Debug
233		+ Eq
234		+ Freeze
235		+ Hash
236		+ Ord
237		+ PartialEq
238		+ PartialEq<[u8]>
239		+ PartialOrd
240		+ RefUnwindSafe
241		+ Send
242		+ Sync
243		+ ToOwned
244		+ Unpin
245		+ UnwindSafe;
246
247	/// See <code>[i32]::[BITS](i32::BITS)</code>.
248	const BITS: u32;
249
250	/// See <code>[i32]::[MIN](i32::MIN)</code>.
251	const MIN: Self;
252
253	/// See <code>[i32]::[MAX](i32::MAX)</code>.
254	const MAX: Self;
255
256	/// Equivalent to <code>Self::[from](From::from)(0i8)</code>.
257	///
258	/// # Examples
259	///
260	/// ```rust
261	/// use multitype::Int;
262	///
263	/// let v0 = i128::ZERO;
264	/// let v1 = 0i128;
265	///
266	/// assert_eq!(v0, v1);
267	/// ```
268	const ZERO: Self;
269
270	/// Equivalent to <code>Self::[from](From::from)(1i8)</code>.
271	///
272	/// # Examples
273	///
274	/// ```rust
275	/// use multitype::Int;
276	///
277	/// let v0 = i128::ONE;
278	/// let v1 = 1i128;
279	///
280	/// assert_eq!(v0, v1);
281	/// ```
282	const ONE: Self;
283
284	/// See <code>[i32]::[from_le](i32::from_le)</code>.
285	#[must_use]
286	fn from_le(value: Self) -> Self;
287
288	/// See <code>[i32]::[from_be](i32::from_be)</code>.
289	#[must_use]
290	fn from_be(value: Self) -> Self;
291
292	/// See <code>[i32]::[from_ne_bytes](i32::from_ne_bytes)</code>.
293	#[must_use]
294	fn from_ne_bytes(bytes: Self::Bytes) -> Self;
295
296	/// See <code>[i32]::[from_le_bytes](i32::from_le_bytes)</code>.
297	#[must_use]
298	fn from_le_bytes(bytes: Self::Bytes) -> Self;
299
300	/// See <code>[i32]::[from_be_bytes](i32::from_be_bytes)</code>.
301	#[must_use]
302	fn from_be_bytes(bytes: Self::Bytes) -> Self;
303
304	/// See <code>[i32]::[from_str_radix](i32::from_str_radix)</code>.
305	fn from_str_radix(s: &str, radix: u32) -> Result<Self, ParseIntError>;
306
307	/// See <code>[i32]::[widening_mul](i32::widening_mul)</code>.
308	#[cfg(feature = "nightly_backports")]
309	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
310	#[must_use]
311	fn widening_mul(self, rhs: Self) -> (Self::Uint, Self);
312
313	/// See <code>[i32]::[div_floor](i32::div_floor)</code>.
314	#[cfg(feature = "nightly_backports")]
315	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
316	#[must_use]
317	fn div_floor(self, rhs: Self) -> Self;
318
319	/// See <code>[i32]::[div_euclid](i32::div_euclid)</code>.
320	#[must_use]
321	fn div_euclid(self, rhs: Self) -> Self;
322
323	/// See <code>[i32]::[exact_div](i32::exact_div)</code>.
324	#[cfg(feature = "nightly_backports")]
325	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
326	#[must_use]
327	fn exact_div(self, rhs: Self) -> Self;
328
329	/// See <code>[i32]::[rem_euclid](i32::rem_euclid)</code>.
330	#[must_use]
331	fn rem_euclid(self, rhs: Self) -> Self;
332
333	/// See <code>[i32]::[exact_shl](i32::exact_shl)</code>.
334	#[cfg(feature = "nightly_backports")]
335	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
336	#[must_use]
337	fn exact_shl(self, rhs: u32) -> Option<Self>;
338
339	/// See <code>[i32]::[exact_shr](i32::exact_shr)</code>.
340	#[cfg(feature = "nightly_backports")]
341	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
342	#[must_use]
343	fn exact_shr(self, rhs: u32) -> Option<Self>;
344
345	/// See <code>[i32]::[rotate_left](i32::rotate_left)</code>.
346	#[must_use]
347	fn rotate_left(self, rhs: u32) -> Self;
348
349	/// See <code>[i32]::[rotate_right](i32::rotate_right)</code>.
350	#[must_use]
351	fn rotate_right(self, rhs: u32) -> Self;
352
353	/// See <code>[i32]::[swap_bytes](i32::swap_bytes)</code>.
354	#[must_use]
355	fn swap_bytes(self) -> Self;
356
357	/// See <code>[i32]::[reverse_bits](i32::reverse_bits)</code>.
358	#[must_use]
359	fn reverse_bits(self) -> Self;
360
361	/// See <code>[i32]::[abs](i32::abs)</code>.
362	#[must_use]
363	fn abs(self) -> Self;
364
365	/// See <code>[i32]::[unsigned_abs](i32::unsigned_abs)</code>.
366	#[must_use]
367	fn unsigned_abs(self) -> Self::Uint;
368
369	/// See <code>[i32]::[pow](i32::pow)</code>.
370	#[must_use]
371	fn pow(self, exp: u32) -> Self;
372
373	/// See <code>[i32]::[isqrt](i32::isqrt)</code>.
374	#[must_use]
375	fn isqrt(self) -> Self;
376
377	/// See <code>[i32]::[ilog](i32::ilog)</code>.
378	#[must_use]
379	fn ilog(self, base: Self) -> u32;
380
381	/// See <code>[i32]::[ilog2](i32::ilog2)</code>.
382	#[must_use]
383	fn ilog2(self) -> u32;
384
385	/// See <code>[i32]::[ilog10](i32::ilog10)</code>.
386	#[must_use]
387	fn ilog10(self) -> u32;
388
389	/// See <code>[i32]::[abs_diff](i32::abs_diff)</code>.
390	#[must_use]
391	fn abs_diff(self, rhs: Self) -> Self::Uint;
392
393	/// See <code>[i32]::[midpoint](i32::midpoint)</code>.
394	#[must_use]
395	fn midpoint(self, rhs: Self) -> Self;
396
397	/// See <code>[i32]::[next_multiple_of](i32::next_multiple_of)</code>.
398	#[cfg(feature = "nightly_backports")]
399	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
400	#[must_use]
401	fn next_multiple_of(self, rhs: Self) -> Self;
402
403	/// See <code>[i32]::[isolate_lowest_one](i32::isolate_lowest_one)</code>.
404	#[cfg(feature = "nightly_backports")]
405	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
406	#[must_use]
407	fn isolate_lowest_one(self) -> Self;
408
409	/// See <code>[i32]::[isolate_highest_one](i32::isolate_highest_one)</code>.
410	#[cfg(feature = "nightly_backports")]
411	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
412	#[must_use]
413	fn isolate_highest_one(self) -> Self;
414
415	/// See <code>[i32]::[lowest_one](i32::lowest_one)</code>.
416	#[cfg(feature = "nightly_backports")]
417	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
418	#[must_use]
419	fn lowest_one(self) -> Option<u32>;
420
421	/// See <code>[i32]::[highest_one](i32::highest_one)</code>.
422	#[cfg(feature = "nightly_backports")]
423	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
424	#[must_use]
425	fn highest_one(self) -> Option<u32>;
426
427	/// See <code>[i32]::[count_zeros](i32::count_zeros)</code>.
428	#[must_use]
429	fn count_zeros(self) -> u32;
430
431	/// See <code>[i32]::[count_ones](i32::count_ones)</code>.
432	#[must_use]
433	fn count_ones(self) -> u32;
434
435	/// See <code>[i32]::[leading_zeros](i32::leading_zeros)</code>.
436	#[must_use]
437	fn leading_zeros(self) -> u32;
438
439	/// See <code>[i32]::[leading_ones](i32::leading_ones)</code>.
440	#[must_use]
441	fn leading_ones(self) -> u32;
442
443	/// See <code>[i32]::[trailing_zeros](i32::trailing_zeros)</code>.
444	#[must_use]
445	fn trailing_zeros(self) -> u32;
446
447	/// See <code>[i32]::[trailing_ones](i32::trailing_ones)</code>.
448	#[must_use]
449	fn trailing_ones(self) -> u32;
450
451	/// See <code>[i32]::[signum](i32::signum)</code>.
452	#[must_use]
453	fn signum(self) -> Self;
454
455	/// See <code>[i32]::[is_negative](i32::is_negative)</code>.
456	#[must_use]
457	fn is_negative(self) -> bool;
458
459	/// See <code>[i32]::[is_positive](i32::is_positive)</code>.
460	#[must_use]
461	fn is_positive(self) -> bool;
462
463	/// See <code>[i32]::[is_multiple_of](i32::is_multiple_of)</code>.
464	#[cfg(feature = "nightly_backports")]
465	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
466	#[must_use]
467	fn is_multiple_of(self, rhs: Self) -> bool;
468
469	/// See <code>[i32]::[checked_add](i32::checked_add)</code>.
470	#[must_use]
471	fn checked_add(self, rhs: Self) -> Option<Self>;
472
473	/// See <code>[i32]::[checked_add_unsigned](i32::checked_add_unsigned)</code>.
474	#[must_use]
475	fn checked_add_unsigned(self, rhs: Self::Uint) -> Option<Self>;
476
477	/// See <code>[i32]::[checked_sub](i32::checked_sub)</code>.
478	#[must_use]
479	fn checked_sub(self, rhs: Self) -> Option<Self>;
480
481	/// See <code>[i32]::[checked_sub_unsigned](i32::checked_sub_unsigned)</code>.
482	#[must_use]
483	fn checked_sub_unsigned(self, rhs: Self::Uint) -> Option<Self>;
484
485	/// See <code>[i32]::[checked_mul](i32::checked_mul)</code>.
486	#[must_use]
487	fn checked_mul(self, rhs: Self) -> Option<Self>;
488
489	/// See <code>[i32]::[checked_div](i32::checked_div)</code>.
490	#[must_use]
491	fn checked_div(self, rhs: Self) -> Option<Self>;
492
493	/// See <code>[i32]::[checked_div_euclid](i32::checked_div_euclid)</code>.
494	#[must_use]
495	fn checked_div_euclid(self, rhs: Self) -> Option<Self>;
496
497	/// See <code>[i32]::[checked_exact_div](i32::checked_exact_div)</code>.
498	#[cfg(feature = "nightly_backports")]
499	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
500	#[must_use]
501	fn checked_exact_div(self, rhs: Self) -> Option<Self>;
502
503	/// See <code>[i32]::[checked_rem](i32::checked_rem)</code>.
504	#[must_use]
505	fn checked_rem(self, rhs: Self) -> Option<Self>;
506
507	/// See <code>[i32]::[checked_rem_euclid](i32::checked_rem_euclid)</code>.
508	#[must_use]
509	fn checked_rem_euclid(self, rhs: Self) -> Option<Self>;
510
511	/// See <code>[i32]::[checked_shl](i32::checked_shl)</code>.
512	#[must_use]
513	fn checked_shl(self, rhs: u32) -> Option<Self>;
514
515	/// See <code>[i32]::[checked_shr](i32::checked_shr)</code>.
516	#[must_use]
517	fn checked_shr(self, rhs: u32) -> Option<Self>;
518
519	/// See <code>[i32]::[checked_neg](i32::checked_neg)</code>.
520	#[must_use]
521	fn checked_neg(self) -> Option<Self>;
522
523	/// See <code>[i32]::[checked_abs](i32::checked_abs)</code>.
524	#[must_use]
525	fn checked_abs(self) -> Option<Self>;
526
527	/// See <code>[i32]::[checked_pow](i32::checked_pow)</code>.
528	#[must_use]
529	fn checked_pow(self, exp: u32) -> Option<Self>;
530
531	/// See <code>[i32]::[checked_ilog](i32::checked_ilog)</code>.
532	#[must_use]
533	fn checked_ilog(self, base: Self) -> Option<u32>;
534
535	/// See <code>[i32]::[checked_ilog2](i32::checked_ilog2)</code>.
536	#[must_use]
537	fn checked_ilog2(self) -> Option<u32>;
538
539	/// See <code>[i32]::[checked_ilog10](i32::checked_ilog10)</code>.
540	#[must_use]
541	fn checked_ilog10(self) -> Option<u32>;
542
543	/// See <code>[i32]::[checked_next_multiple_of](i32::checked_next_multiple_of)</code>.
544	#[cfg(feature = "nightly_backports")]
545	#[must_use]
546	fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>;
547
548	/// See <code>[i32]::[strict_add](i32::strict_add)</code>.
549	#[must_use]
550	fn strict_add(self, rhs: Self) -> Self;
551
552	/// See <code>[i32]::[strict_add_unsigned](i32::strict_add_unsigned)</code>.
553	#[must_use]
554	fn strict_add_unsigned(self, rhs: Self::Uint) -> Self;
555
556	/// See <code>[i32]::[strict_sub](i32::strict_sub)</code>.
557	#[must_use]
558	fn strict_sub(self, rhs: Self) -> Self;
559
560	/// See <code>[i32]::[strict_sub_unsigned](i32::strict_sub_unsigned)</code>.
561	#[must_use]
562	fn strict_sub_unsigned(self, rhs: Self::Uint) -> Self;
563
564	/// See <code>[i32]::[strict_mul](i32::strict_mul)</code>.
565	#[must_use]
566	fn strict_mul(self, rhs: Self) -> Self;
567
568	/// See <code>[i32]::[strict_div](i32::strict_div)</code>.
569	#[must_use]
570	fn strict_div(self, rhs: Self) -> Self;
571
572	/// See <code>[i32]::[strict_div_euclid](i32::strict_div_euclid)</code>.
573	#[must_use]
574	fn strict_div_euclid(self, rhs: Self) -> Self;
575
576	/// See <code>[i32]::[strict_rem](i32::strict_rem)</code>.
577	#[must_use]
578	fn strict_rem(self, rhs: Self) -> Self;
579
580	/// See <code>[i32]::[strict_rem_euclid](i32::strict_rem_euclid)</code>.
581	#[must_use]
582	fn strict_rem_euclid(self, rhs: Self) -> Self;
583
584	/// See <code>[i32]::[strict_shl](i32::strict_shl)</code>.
585	#[must_use]
586	fn strict_shl(self, rhs: u32) -> Self;
587
588	/// See <code>[i32]::[strict_shr](i32::strict_shr)</code>.
589	#[must_use]
590	fn strict_shr(self, rhs: u32) -> Self;
591
592	/// See <code>[i32]::[strict_neg](i32::strict_neg)</code>.
593	#[must_use]
594	fn strict_neg(self) -> Self;
595
596	/// See <code>[i32]::[strict_abs](i32::strict_abs)</code>.
597	#[must_use]
598	fn strict_abs(self) -> Self;
599
600	/// See <code>[i32]::[strict_pow](i32::strict_pow)</code>.
601	#[must_use]
602	fn strict_pow(self, rhs: u32) -> Self;
603
604	/// See <code>[i32]::[unchecked_add](i32::unchecked_add)</code>.
605	#[expect(clippy::missing_safety_doc)]
606	#[must_use]
607	unsafe fn unchecked_add(self, rhs: Self) -> Self;
608
609	/// See <code>[i32]::[unchecked_exact_div](i32::unchecked_exact_div)</code>.
610	#[cfg(feature = "nightly_backports")]
611	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
612	#[expect(clippy::missing_safety_doc)]
613	#[must_use]
614	unsafe fn unchecked_exact_div(self, rhs: Self) -> Self;
615
616	/// See <code>[i32]::[unchecked_sub](i32::unchecked_sub)</code>.
617	#[expect(clippy::missing_safety_doc)]
618	#[must_use]
619	unsafe fn unchecked_sub(self, rhs: Self) -> Self;
620
621	/// See <code>[i32]::[unchecked_mul](i32::unchecked_mul)</code>.
622	#[expect(clippy::missing_safety_doc)]
623	#[must_use]
624	unsafe fn unchecked_mul(self, rhs: Self) -> Self;
625
626	/// See <code>[i32]::[unchecked_shl](i32::unchecked_shl)</code>.
627	#[cfg(feature = "nightly_backports")]
628	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
629	#[expect(clippy::missing_safety_doc)]
630	#[must_use]
631	unsafe fn unchecked_shl(self, rhs: u32) -> Self;
632
633	/// See <code>[i32]::[unchecked_shr](i32::unchecked_shr)</code>.
634	#[cfg(feature = "nightly_backports")]
635	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
636	#[expect(clippy::missing_safety_doc)]
637	#[must_use]
638	unsafe fn unchecked_shr(self, rhs: u32) -> Self;
639
640	/// See <code>[i32]::[unchecked_exact_shl](i32::unchecked_exact_shl)</code>.
641	#[cfg(feature = "nightly_backports")]
642	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
643	#[expect(clippy::missing_safety_doc)]
644	#[must_use]
645	unsafe fn unchecked_exact_shl(self, rhs: u32) -> Self;
646
647	/// See <code>[i32]::[unchecked_exact_shr](i32::unchecked_exact_shr)</code>.
648	#[cfg(feature = "nightly_backports")]
649	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
650	#[expect(clippy::missing_safety_doc)]
651	#[must_use]
652	unsafe fn unchecked_exact_shr(self, rhs: u32) -> Self;
653
654	/// See <code>[i32]::[unchecked_neg](i32::unchecked_neg)</code>.
655	#[cfg(feature = "nightly_backports")]
656	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
657	#[expect(clippy::missing_safety_doc)]
658	#[must_use]
659	unsafe fn unchecked_neg(self) -> Self;
660
661	/// See <code>[i32]::[overflowing_add](i32::overflowing_add)</code>.
662	#[must_use]
663	fn overflowing_add(self, rhs: Self) -> (Self, bool);
664
665	/// See <code>[i32]::[overflowing_add_unsigned](i32::overflowing_add_unsigned)</code>.
666	#[must_use]
667	fn overflowing_add_unsigned(self, rhs: Self::Uint) -> (Self, bool);
668
669	/// See <code>[i32]::[overflowing_sub](i32::overflowing_sub)</code>.
670	#[must_use]
671	fn overflowing_sub(self, rhs: Self) -> (Self, bool);
672
673	/// See <code>[i32]::[overflowing_sub_unsigned](i32::overflowing_sub_unsigned)</code>.
674	#[must_use]
675	fn overflowing_sub_unsigned(self, rhs: Self::Uint) -> (Self, bool);
676
677	/// See <code>[i32]::[overflowing_mul](i32::overflowing_mul)</code>.
678	#[must_use]
679	fn overflowing_mul(self, rhs: Self) -> (Self, bool);
680
681	/// See <code>[i32]::[overflowing_div](i32::overflowing_div)</code>.
682	#[must_use]
683	fn overflowing_div(self, rhs: Self) -> (Self, bool);
684
685	/// See <code>[i32]::[overflowing_div_euclid](i32::overflowing_div_euclid)</code>.
686	#[must_use]
687	fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool);
688
689	/// See <code>[i32]::[overflowing_rem](i32::overflowing_rem)</code>.
690	#[must_use]
691	fn overflowing_rem(self, rhs: Self) -> (Self, bool);
692
693	/// See <code>[i32]::[overflowing_rem_euclid](i32::overflowing_rem_euclid)</code>.
694	#[must_use]
695	fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool);
696
697	/// See <code>[i32]::[overflowing_shl](i32::overflowing_shl)</code>.
698	#[must_use]
699	fn overflowing_shl(self, rhs: u32) -> (Self, bool);
700
701	/// See <code>[i32]::[overflowing_shr](i32::overflowing_shr)</code>.
702	#[must_use]
703	fn overflowing_shr(self, rhs: u32) -> (Self, bool);
704
705	/// See <code>[i32]::[overflowing_neg](i32::overflowing_neg)</code>.
706	#[must_use]
707	fn overflowing_neg(self) -> (Self, bool);
708
709	/// See <code>[i32]::[overflowing_abs](i32::overflowing_abs)</code>.
710	#[must_use]
711	fn overflowing_abs(self) -> (Self, bool);
712
713	/// See <code>[i32]::[overflowing_pow](i32::overflowing_pow)</code>.
714	#[must_use]
715	fn overflowing_pow(self, exp: u32) -> (Self, bool);
716
717	/// See <code>[i32]::[carrying_add](i32::carrying_add)</code>.
718	#[cfg(feature = "nightly_backports")]
719	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
720	#[must_use]
721	fn carrying_add(self, rhs: Self, carry: bool) -> (Self, bool);
722
723	/// See <code>[i32]::[carrying_mul](i32::carrying_mul)</code>.
724	#[cfg(feature = "nightly_backports")]
725	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
726	#[must_use]
727	fn carrying_mul(self, rhs: Self, carry: Self) -> (Self::Uint, Self);
728
729	/// See <code>[i32]::[carrying_mul_add](i32::carrying_mul_add)</code>.
730	#[cfg(feature = "nightly_backports")]
731	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
732	#[must_use]
733	fn carrying_mul_add(self, mul: Self, add: Self, carry: Self) -> (Self::Uint, Self);
734
735	/// See <code>[i32]::[borrowing_sub](i32::borrowing_sub)</code>.
736	#[cfg(feature = "nightly_backports")]
737	#[cfg_attr(feature = "unstable_docs", doc(cfg(feature = "nightly_backports")))]
738	#[must_use]
739	fn borrowing_sub(self, rhs: Self, borrow: bool) -> (Self, bool);
740
741	/// See <code>[i32]::[wrapping_add](i32::wrapping_add)</code>.
742	#[must_use]
743	fn wrapping_add(self, rhs: Self) -> Self;
744
745	/// See <code>[i32]::[wrapping_add_unsigned](i32::wrapping_add_unsigned)</code>.
746	#[must_use]
747	fn wrapping_add_unsigned(self, rhs: Self::Uint) -> Self;
748
749	/// See <code>[i32]::[wrapping_sub](i32::wrapping_sub)</code>.
750	#[must_use]
751	fn wrapping_sub(self, rhs: Self) -> Self;
752
753	/// See <code>[i32]::[wrapping_sub_unsigned](i32::wrapping_sub_unsigned)</code>.
754	#[must_use]
755	fn wrapping_sub_unsigned(self, rhs: Self::Uint) -> Self;
756
757	/// See <code>[i32]::[wrapping_mul](i32::wrapping_mul)</code>.
758	#[must_use]
759	fn wrapping_mul(self, rhs: Self) -> Self;
760
761	/// See <code>[i32]::[wrapping_div](i32::wrapping_div)</code>.
762	#[must_use]
763	fn wrapping_div(self, rhs: Self) -> Self;
764
765	/// See <code>[i32]::[wrapping_div_euclid](i32::wrapping_div_euclid)</code>.
766	#[must_use]
767	fn wrapping_div_euclid(self, rhs: Self) -> Self;
768
769	/// See <code>[i32]::[wrapping_rem](i32::wrapping_rem)</code>.
770	#[must_use]
771	fn wrapping_rem(self, rhs: Self) -> Self;
772
773	/// See <code>[i32]::[wrapping_rem_euclid](i32::wrapping_rem_euclid)</code>.
774	#[must_use]
775	fn wrapping_rem_euclid(self, rhs: Self) -> Self;
776
777	/// See <code>[i32]::[wrapping_shl](i32::wrapping_shl)</code>.
778	#[must_use]
779	fn wrapping_shl(self, rhs: u32) -> Self;
780
781	/// See <code>[i32]::[wrapping_shr](i32::wrapping_shr)</code>.
782	#[must_use]
783	fn wrapping_shr(self, rhs: u32) -> Self;
784
785	/// See <code>[i32]::[wrapping_neg](i32::wrapping_neg)</code>.
786	#[must_use]
787	fn wrapping_neg(self) -> Self;
788
789	/// See <code>[i32]::[wrapping_abs](i32::wrapping_abs)</code>.
790	#[must_use]
791	fn wrapping_abs(self) -> Self;
792
793	/// See <code>[i32]::[wrapping_pow](i32::wrapping_pow)</code>.
794	#[must_use]
795	fn wrapping_pow(self, exp: u32) -> Self;
796
797	/// See <code>[i32]::[saturating_add](i32::saturating_add)</code>.
798	#[must_use]
799	fn saturating_add(self, rhs: Self) -> Self;
800
801	/// See <code>[i32]::[saturating_add_unsigned](i32::saturating_add_unsigned)</code>.
802	#[must_use]
803	fn saturating_add_unsigned(self, rhs: Self::Uint) -> Self;
804
805	/// See <code>[i32]::[saturating_sub](i32::saturating_sub)</code>.
806	#[must_use]
807	fn saturating_sub(self, rhs: Self) -> Self;
808
809	/// See <code>[i32]::[saturating_sub_unsigned](i32::saturating_sub_unsigned)</code>.
810	#[must_use]
811	fn saturating_sub_unsigned(self, rhs: Self::Uint) -> Self;
812
813	/// See <code>[i32]::[saturating_mul](i32::saturating_mul)</code>.
814	#[must_use]
815	fn saturating_mul(self, rhs: Self) -> Self;
816
817	/// See <code>[i32]::[saturating_div](i32::saturating_div)</code>.
818	#[must_use]
819	fn saturating_div(self, rhs: Self) -> Self;
820
821	/// See <code>[i32]::[saturating_neg](i32::saturating_neg)</code>.
822	#[must_use]
823	fn saturating_neg(self) -> Self;
824
825	/// See <code>[i32]::[saturating_abs](i32::saturating_abs)</code>.
826	#[must_use]
827	fn saturating_abs(self) -> Self;
828
829	/// See <code>[i32]::[saturating_pow](i32::saturating_pow)</code>.
830	#[must_use]
831	fn saturating_pow(self, exp: u32) -> Self;
832
833	/// See <code>[i32]::[unbounded_shl](i32::unbounded_shl)</code>.
834	#[must_use]
835	fn unbounded_shl(self, rhs: u32) -> Self;
836
837	/// See <code>[i32]::[unbounded_shr](i32::unbounded_shr)</code>.
838	#[must_use]
839	fn unbounded_shr(self, rhs: u32) -> Self;
840
841	/// Reinterprets `self` as an unsigned integer.
842	#[must_use]
843	fn cast_unsigned(self) -> Self::Uint;
844
845	/// See <code>[i32]::[to_le](i32::to_le)</code>.
846	#[must_use]
847	fn to_le(self) -> Self;
848
849	/// See <code>[i32]::[to_be](i32::to_be)</code>.
850	#[must_use]
851	fn to_be(self) -> Self;
852
853	/// See <code>[i32]::[to_ne_bytes](i32::to_ne_bytes)</code>.
854	#[must_use]
855	fn to_ne_bytes(self) -> Self::Bytes;
856
857	/// See <code>[i32]::[to_le_bytes](i32::to_le_bytes)</code>.
858	#[must_use]
859	fn to_le_bytes(self) -> Self::Bytes;
860
861	/// See <code>[i32]::[to_be_bytes](i32::to_be_bytes)</code>.
862	#[must_use]
863	fn to_be_bytes(self) -> Self::Bytes;
864}