use core::fmt::NumBuffer;
use core::num::{NonZero, ParseIntError, TryFromIntError};
use crate::{PrimitiveError, PrimitiveNumber, PrimitiveNumberRef};
trait Sealed {}
pub trait PrimitiveInteger:
PrimitiveNumber
+ core::cmp::Eq
+ core::cmp::Ord
+ core::convert::From<Self::NonZero>
+ core::convert::TryFrom<i8, Error: PrimitiveError>
+ core::convert::TryFrom<i16, Error: PrimitiveError>
+ core::convert::TryFrom<i32, Error: PrimitiveError>
+ core::convert::TryFrom<i64, Error: PrimitiveError>
+ core::convert::TryFrom<i128, Error: PrimitiveError>
+ core::convert::TryFrom<isize, Error: PrimitiveError>
+ core::convert::TryFrom<u8, Error: PrimitiveError>
+ core::convert::TryFrom<u16, Error: PrimitiveError>
+ core::convert::TryFrom<u32, Error: PrimitiveError>
+ core::convert::TryFrom<u64, Error: PrimitiveError>
+ core::convert::TryFrom<u128, Error: PrimitiveError>
+ core::convert::TryFrom<usize, Error: PrimitiveError>
+ core::convert::TryInto<Self::NonZero, Error = TryFromIntError>
+ core::convert::TryInto<i8, Error: PrimitiveError>
+ core::convert::TryInto<i16, Error: PrimitiveError>
+ core::convert::TryInto<i32, Error: PrimitiveError>
+ core::convert::TryInto<i64, Error: PrimitiveError>
+ core::convert::TryInto<i128, Error: PrimitiveError>
+ core::convert::TryInto<isize, Error: PrimitiveError>
+ core::convert::TryInto<u8, Error: PrimitiveError>
+ core::convert::TryInto<u16, Error: PrimitiveError>
+ core::convert::TryInto<u32, Error: PrimitiveError>
+ core::convert::TryInto<u64, Error: PrimitiveError>
+ core::convert::TryInto<u128, Error: PrimitiveError>
+ core::convert::TryInto<usize, Error: PrimitiveError>
+ core::fmt::Binary
+ core::fmt::LowerHex
+ core::fmt::Octal
+ core::fmt::UpperHex
+ core::hash::Hash
+ core::ops::BitAnd<Self, Output = Self>
+ core::ops::BitAndAssign<Self>
+ core::ops::BitOr<Self, Output = Self>
+ core::ops::BitOr<Self::NonZero, Output = Self::NonZero>
+ core::ops::BitOrAssign<Self>
+ core::ops::BitXor<Self, Output = Self>
+ core::ops::BitXorAssign<Self>
+ core::ops::Not<Output = Self>
+ core::ops::Shl<Self, Output = Self>
+ core::ops::Shl<i8, Output = Self>
+ core::ops::Shl<i16, Output = Self>
+ core::ops::Shl<i32, Output = Self>
+ core::ops::Shl<i64, Output = Self>
+ core::ops::Shl<i128, Output = Self>
+ core::ops::Shl<isize, Output = Self>
+ core::ops::Shl<u8, Output = Self>
+ core::ops::Shl<u16, Output = Self>
+ core::ops::Shl<u32, Output = Self>
+ core::ops::Shl<u64, Output = Self>
+ core::ops::Shl<u128, Output = Self>
+ core::ops::Shl<usize, Output = Self>
+ core::ops::ShlAssign<Self>
+ core::ops::ShlAssign<i8>
+ core::ops::ShlAssign<i16>
+ core::ops::ShlAssign<i32>
+ core::ops::ShlAssign<i64>
+ core::ops::ShlAssign<i128>
+ core::ops::ShlAssign<isize>
+ core::ops::ShlAssign<u8>
+ core::ops::ShlAssign<u16>
+ core::ops::ShlAssign<u32>
+ core::ops::ShlAssign<u64>
+ core::ops::ShlAssign<u128>
+ core::ops::ShlAssign<usize>
+ core::ops::Shr<Self, Output = Self>
+ core::ops::Shr<i8, Output = Self>
+ core::ops::Shr<i16, Output = Self>
+ core::ops::Shr<i32, Output = Self>
+ core::ops::Shr<i64, Output = Self>
+ core::ops::Shr<i128, Output = Self>
+ core::ops::Shr<isize, Output = Self>
+ core::ops::Shr<u8, Output = Self>
+ core::ops::Shr<u16, Output = Self>
+ core::ops::Shr<u32, Output = Self>
+ core::ops::Shr<u64, Output = Self>
+ core::ops::Shr<u128, Output = Self>
+ core::ops::Shr<usize, Output = Self>
+ core::ops::ShrAssign<Self>
+ core::ops::ShrAssign<i8>
+ core::ops::ShrAssign<i16>
+ core::ops::ShrAssign<i32>
+ core::ops::ShrAssign<i64>
+ core::ops::ShrAssign<i128>
+ core::ops::ShrAssign<isize>
+ core::ops::ShrAssign<u8>
+ core::ops::ShrAssign<u16>
+ core::ops::ShrAssign<u32>
+ core::ops::ShrAssign<u64>
+ core::ops::ShrAssign<u128>
+ core::ops::ShrAssign<usize>
+ core::str::FromStr<Err = ParseIntError>
+ for<'a> core::ops::BitAnd<&'a Self, Output = Self>
+ for<'a> core::ops::BitAndAssign<&'a Self>
+ for<'a> core::ops::BitOr<&'a Self, Output = Self>
+ for<'a> core::ops::BitOrAssign<&'a Self>
+ for<'a> core::ops::BitXor<&'a Self, Output = Self>
+ for<'a> core::ops::BitXorAssign<&'a Self>
+ for<'a> core::ops::Shl<&'a Self, Output = Self>
+ for<'a> core::ops::Shl<&'a i8, Output = Self>
+ for<'a> core::ops::Shl<&'a i16, Output = Self>
+ for<'a> core::ops::Shl<&'a i32, Output = Self>
+ for<'a> core::ops::Shl<&'a i64, Output = Self>
+ for<'a> core::ops::Shl<&'a i128, Output = Self>
+ for<'a> core::ops::Shl<&'a isize, Output = Self>
+ for<'a> core::ops::Shl<&'a u8, Output = Self>
+ for<'a> core::ops::Shl<&'a u16, Output = Self>
+ for<'a> core::ops::Shl<&'a u32, Output = Self>
+ for<'a> core::ops::Shl<&'a u64, Output = Self>
+ for<'a> core::ops::Shl<&'a u128, Output = Self>
+ for<'a> core::ops::Shl<&'a usize, Output = Self>
+ for<'a> core::ops::ShlAssign<&'a Self>
+ for<'a> core::ops::ShlAssign<&'a i8>
+ for<'a> core::ops::ShlAssign<&'a i16>
+ for<'a> core::ops::ShlAssign<&'a i32>
+ for<'a> core::ops::ShlAssign<&'a i64>
+ for<'a> core::ops::ShlAssign<&'a i128>
+ for<'a> core::ops::ShlAssign<&'a isize>
+ for<'a> core::ops::ShlAssign<&'a u8>
+ for<'a> core::ops::ShlAssign<&'a u16>
+ for<'a> core::ops::ShlAssign<&'a u32>
+ for<'a> core::ops::ShlAssign<&'a u64>
+ for<'a> core::ops::ShlAssign<&'a u128>
+ for<'a> core::ops::ShlAssign<&'a usize>
+ for<'a> core::ops::Shr<&'a Self, Output = Self>
+ for<'a> core::ops::Shr<&'a i8, Output = Self>
+ for<'a> core::ops::Shr<&'a i16, Output = Self>
+ for<'a> core::ops::Shr<&'a i32, Output = Self>
+ for<'a> core::ops::Shr<&'a i64, Output = Self>
+ for<'a> core::ops::Shr<&'a i128, Output = Self>
+ for<'a> core::ops::Shr<&'a isize, Output = Self>
+ for<'a> core::ops::Shr<&'a u8, Output = Self>
+ for<'a> core::ops::Shr<&'a u16, Output = Self>
+ for<'a> core::ops::Shr<&'a u32, Output = Self>
+ for<'a> core::ops::Shr<&'a u64, Output = Self>
+ for<'a> core::ops::Shr<&'a u128, Output = Self>
+ for<'a> core::ops::Shr<&'a usize, Output = Self>
+ for<'a> core::ops::ShrAssign<&'a Self>
+ for<'a> core::ops::ShrAssign<&'a i8>
+ for<'a> core::ops::ShrAssign<&'a i16>
+ for<'a> core::ops::ShrAssign<&'a i32>
+ for<'a> core::ops::ShrAssign<&'a i64>
+ for<'a> core::ops::ShrAssign<&'a i128>
+ for<'a> core::ops::ShrAssign<&'a isize>
+ for<'a> core::ops::ShrAssign<&'a u8>
+ for<'a> core::ops::ShrAssign<&'a u16>
+ for<'a> core::ops::ShrAssign<&'a u32>
+ for<'a> core::ops::ShrAssign<&'a u64>
+ for<'a> core::ops::ShrAssign<&'a u128>
+ for<'a> core::ops::ShrAssign<&'a usize>
{
type NonZero: NonZeroPrimitiveInteger<Integer = Self>;
type NumBuffer: PrimitiveNumBuffer;
const BITS: u32;
const MAX: Self;
const MIN: Self;
fn checked_add(self, rhs: Self) -> Option<Self>;
fn checked_div(self, rhs: Self) -> Option<Self>;
fn checked_div_euclid(self, rhs: Self) -> Option<Self>;
fn checked_ilog(self, base: Self) -> Option<u32>;
fn checked_ilog10(self) -> Option<u32>;
fn checked_ilog2(self) -> Option<u32>;
fn checked_mul(self, rhs: Self) -> Option<Self>;
fn checked_neg(self) -> Option<Self>;
fn checked_pow(self, exp: u32) -> Option<Self>;
fn checked_rem(self, rhs: Self) -> Option<Self>;
fn checked_rem_euclid(self, rhs: Self) -> Option<Self>;
fn checked_shl(self, rhs: u32) -> Option<Self>;
fn checked_shr(self, rhs: u32) -> Option<Self>;
fn checked_sub(self, rhs: Self) -> Option<Self>;
fn count_ones(self) -> u32;
fn count_zeros(self) -> u32;
fn div_euclid(self, rhs: Self) -> Self;
fn format_into(self, buf: &mut Self::NumBuffer) -> &str;
fn from_be(value: Self) -> Self;
fn from_le(value: Self) -> Self;
fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
fn highest_one(self) -> Option<u32>;
fn ilog(self, base: Self) -> u32;
fn ilog10(self) -> u32;
fn ilog2(self) -> u32;
fn isolate_highest_one(self) -> Self;
fn isolate_lowest_one(self) -> Self;
fn isqrt(self) -> Self;
fn leading_ones(self) -> u32;
fn leading_zeros(self) -> u32;
fn lowest_one(self) -> Option<u32>;
fn overflowing_add(self, rhs: Self) -> (Self, bool);
fn overflowing_div(self, rhs: Self) -> (Self, bool);
fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool);
fn overflowing_mul(self, rhs: Self) -> (Self, bool);
fn overflowing_neg(self) -> (Self, bool);
fn overflowing_pow(self, exp: u32) -> (Self, bool);
fn overflowing_rem(self, rhs: Self) -> (Self, bool);
fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool);
fn overflowing_shl(self, rhs: u32) -> (Self, bool);
fn overflowing_shr(self, rhs: u32) -> (Self, bool);
fn overflowing_sub(self, rhs: Self) -> (Self, bool);
fn pow(self, exp: u32) -> Self;
fn rem_euclid(self, rhs: Self) -> Self;
fn reverse_bits(self) -> Self;
fn rotate_left(self, n: u32) -> Self;
fn rotate_right(self, n: u32) -> Self;
fn saturating_add(self, rhs: Self) -> Self;
fn saturating_div(self, rhs: Self) -> Self;
fn saturating_mul(self, rhs: Self) -> Self;
fn saturating_pow(self, exp: u32) -> Self;
fn saturating_sub(self, rhs: Self) -> Self;
fn strict_add(self, rhs: Self) -> Self;
fn strict_div(self, rhs: Self) -> Self;
fn strict_div_euclid(self, rhs: Self) -> Self;
fn strict_mul(self, rhs: Self) -> Self;
fn strict_neg(self) -> Self;
fn strict_pow(self, exp: u32) -> Self;
fn strict_rem(self, rhs: Self) -> Self;
fn strict_rem_euclid(self, rhs: Self) -> Self;
fn strict_shl(self, rhs: u32) -> Self;
fn strict_shr(self, rhs: u32) -> Self;
fn strict_sub(self, rhs: Self) -> Self;
fn swap_bytes(self) -> Self;
fn to_be(self) -> Self;
fn to_le(self) -> Self;
fn trailing_ones(self) -> u32;
fn trailing_zeros(self) -> u32;
fn unbounded_shl(self, rhs: u32) -> Self;
fn unbounded_shr(self, rhs: u32) -> Self;
fn wrapping_add(self, rhs: Self) -> Self;
fn wrapping_div(self, rhs: Self) -> Self;
fn wrapping_div_euclid(self, rhs: Self) -> Self;
fn wrapping_mul(self, rhs: Self) -> Self;
fn wrapping_neg(self) -> Self;
fn wrapping_pow(self, exp: u32) -> Self;
fn wrapping_rem(self, rhs: Self) -> Self;
fn wrapping_rem_euclid(self, rhs: Self) -> Self;
fn wrapping_shl(self, rhs: u32) -> Self;
fn wrapping_shr(self, rhs: u32) -> Self;
fn wrapping_sub(self, rhs: Self) -> Self;
unsafe fn unchecked_add(self, rhs: Self) -> Self;
unsafe fn unchecked_mul(self, rhs: Self) -> Self;
unsafe fn unchecked_shl(self, rhs: u32) -> Self;
unsafe fn unchecked_shr(self, rhs: u32) -> Self;
unsafe fn unchecked_sub(self, rhs: Self) -> Self;
}
pub trait PrimitiveIntegerRef<T>:
PrimitiveNumberRef<T>
+ core::cmp::Eq
+ core::cmp::Ord
+ core::fmt::Binary
+ core::fmt::LowerHex
+ core::fmt::Octal
+ core::fmt::UpperHex
+ core::hash::Hash
+ core::ops::BitAnd<T, Output = T>
+ core::ops::BitOr<T, Output = T>
+ core::ops::BitXor<T, Output = T>
+ core::ops::Not<Output = T>
+ core::ops::Shl<T, Output = T>
+ core::ops::Shl<i8, Output = T>
+ core::ops::Shl<i16, Output = T>
+ core::ops::Shl<i32, Output = T>
+ core::ops::Shl<i64, Output = T>
+ core::ops::Shl<i128, Output = T>
+ core::ops::Shl<isize, Output = T>
+ core::ops::Shl<u8, Output = T>
+ core::ops::Shl<u16, Output = T>
+ core::ops::Shl<u32, Output = T>
+ core::ops::Shl<u64, Output = T>
+ core::ops::Shl<u128, Output = T>
+ core::ops::Shl<usize, Output = T>
+ core::ops::Shr<T, Output = T>
+ core::ops::Shr<i8, Output = T>
+ core::ops::Shr<i16, Output = T>
+ core::ops::Shr<i32, Output = T>
+ core::ops::Shr<i64, Output = T>
+ core::ops::Shr<i128, Output = T>
+ core::ops::Shr<isize, Output = T>
+ core::ops::Shr<u8, Output = T>
+ core::ops::Shr<u16, Output = T>
+ core::ops::Shr<u32, Output = T>
+ core::ops::Shr<u64, Output = T>
+ core::ops::Shr<u128, Output = T>
+ core::ops::Shr<usize, Output = T>
+ for<'a> core::ops::BitAnd<&'a T, Output = T>
+ for<'a> core::ops::BitOr<&'a T, Output = T>
+ for<'a> core::ops::BitXor<&'a T, Output = T>
+ for<'a> core::ops::Shl<&'a T, Output = T>
+ for<'a> core::ops::Shl<&'a i8, Output = T>
+ for<'a> core::ops::Shl<&'a i16, Output = T>
+ for<'a> core::ops::Shl<&'a i32, Output = T>
+ for<'a> core::ops::Shl<&'a i64, Output = T>
+ for<'a> core::ops::Shl<&'a i128, Output = T>
+ for<'a> core::ops::Shl<&'a isize, Output = T>
+ for<'a> core::ops::Shl<&'a u8, Output = T>
+ for<'a> core::ops::Shl<&'a u16, Output = T>
+ for<'a> core::ops::Shl<&'a u32, Output = T>
+ for<'a> core::ops::Shl<&'a u64, Output = T>
+ for<'a> core::ops::Shl<&'a u128, Output = T>
+ for<'a> core::ops::Shl<&'a usize, Output = T>
+ for<'a> core::ops::Shr<&'a T, Output = T>
+ for<'a> core::ops::Shr<&'a i8, Output = T>
+ for<'a> core::ops::Shr<&'a i16, Output = T>
+ for<'a> core::ops::Shr<&'a i32, Output = T>
+ for<'a> core::ops::Shr<&'a i64, Output = T>
+ for<'a> core::ops::Shr<&'a i128, Output = T>
+ for<'a> core::ops::Shr<&'a isize, Output = T>
+ for<'a> core::ops::Shr<&'a u8, Output = T>
+ for<'a> core::ops::Shr<&'a u16, Output = T>
+ for<'a> core::ops::Shr<&'a u32, Output = T>
+ for<'a> core::ops::Shr<&'a u64, Output = T>
+ for<'a> core::ops::Shr<&'a u128, Output = T>
+ for<'a> core::ops::Shr<&'a usize, Output = T>
{
}
#[expect(private_bounds)]
pub trait NonZeroPrimitiveInteger:
'static
+ Sealed
+ core::cmp::Eq
+ core::cmp::Ord
+ core::convert::Into<Self::Integer>
+ core::convert::TryFrom<Self::Integer, Error = TryFromIntError>
+ core::convert::TryFrom<NonZero<i8>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<i16>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<i32>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<i64>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<i128>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<isize>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<u8>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<u16>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<u32>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<u64>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<u128>, Error: PrimitiveError>
+ core::convert::TryFrom<NonZero<usize>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<i8>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<i16>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<i32>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<i64>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<i128>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<isize>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<u8>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<u16>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<u32>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<u64>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<u128>, Error: PrimitiveError>
+ core::convert::TryInto<NonZero<usize>, Error: PrimitiveError>
+ core::fmt::Binary
+ core::fmt::Debug
+ core::fmt::Display
+ core::fmt::LowerExp
+ core::fmt::LowerHex
+ core::fmt::Octal
+ core::fmt::UpperExp
+ core::fmt::UpperHex
+ core::hash::Hash
+ core::marker::Copy
+ core::marker::Send
+ core::marker::Sync
+ core::marker::Unpin
+ core::ops::BitOr<Self, Output = Self>
+ core::ops::BitOr<Self::Integer, Output = Self>
+ core::ops::BitOrAssign<Self>
+ core::ops::BitOrAssign<Self::Integer>
+ core::panic::RefUnwindSafe
+ core::panic::UnwindSafe
+ core::str::FromStr<Err = ParseIntError>
{
type Integer: PrimitiveInteger<NonZero = Self>;
const BITS: u32;
const MAX: Self;
const MIN: Self;
fn checked_mul(self, other: Self) -> Option<Self>;
fn checked_pow(self, other: u32) -> Option<Self>;
fn count_ones(self) -> NonZero<u32>;
fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
fn get(self) -> Self::Integer;
fn highest_one(self) -> u32;
fn isolate_highest_one(self) -> Self;
fn isolate_lowest_one(self) -> Self;
fn leading_zeros(self) -> u32;
fn lowest_one(self) -> u32;
fn new(n: Self::Integer) -> Option<Self>;
fn saturating_mul(self, other: Self) -> Self;
fn saturating_pow(self, other: u32) -> Self;
fn trailing_zeros(self) -> u32;
unsafe fn new_unchecked(n: Self::Integer) -> Self;
}
#[expect(private_bounds)]
pub trait PrimitiveNumBuffer:
'static
+ Sealed
+ core::fmt::Debug
+ core::marker::Send
+ core::marker::Sized
+ core::marker::Sync
+ core::marker::Unpin
+ core::panic::RefUnwindSafe
+ core::panic::UnwindSafe
{
fn new() -> Self;
}
macro_rules! impl_integer {
($($Integer:ident),*) => {$(
impl PrimitiveInteger for $Integer {
type NonZero = NonZero<Self>;
type NumBuffer = NumBuffer<Self>;
use_consts!(Self::{
BITS: u32,
MAX: Self,
MIN: Self,
});
forward! {
fn from_be(value: Self) -> Self;
fn from_le(value: Self) -> Self;
fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
}
forward! {
fn checked_add(self, rhs: Self) -> Option<Self>;
fn checked_div(self, rhs: Self) -> Option<Self>;
fn checked_div_euclid(self, rhs: Self) -> Option<Self>;
fn checked_ilog(self, base: Self) -> Option<u32>;
fn checked_ilog10(self) -> Option<u32>;
fn checked_ilog2(self) -> Option<u32>;
fn checked_mul(self, rhs: Self) -> Option<Self>;
fn checked_neg(self) -> Option<Self>;
fn checked_pow(self, exp: u32) -> Option<Self>;
fn checked_rem(self, rhs: Self) -> Option<Self>;
fn checked_rem_euclid(self, rhs: Self) -> Option<Self>;
fn checked_shl(self, rhs: u32) -> Option<Self>;
fn checked_shr(self, rhs: u32) -> Option<Self>;
fn checked_sub(self, rhs: Self) -> Option<Self>;
fn count_ones(self) -> u32;
fn count_zeros(self) -> u32;
fn div_euclid(self, rhs: Self) -> Self;
fn format_into(self, buf: &mut Self::NumBuffer) -> &str;
fn highest_one(self) -> Option<u32>;
fn ilog(self, base: Self) -> u32;
fn ilog10(self) -> u32;
fn ilog2(self) -> u32;
fn isolate_highest_one(self) -> Self;
fn isolate_lowest_one(self) -> Self;
fn isqrt(self) -> Self;
fn leading_ones(self) -> u32;
fn leading_zeros(self) -> u32;
fn lowest_one(self) -> Option<u32>;
fn overflowing_add(self, rhs: Self) -> (Self, bool);
fn overflowing_div(self, rhs: Self) -> (Self, bool);
fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool);
fn overflowing_mul(self, rhs: Self) -> (Self, bool);
fn overflowing_neg(self) -> (Self, bool);
fn overflowing_pow(self, exp: u32) -> (Self, bool);
fn overflowing_rem(self, rhs: Self) -> (Self, bool);
fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool);
fn overflowing_shl(self, rhs: u32) -> (Self, bool);
fn overflowing_shr(self, rhs: u32) -> (Self, bool);
fn overflowing_sub(self, rhs: Self) -> (Self, bool);
fn pow(self, exp: u32) -> Self;
fn rem_euclid(self, rhs: Self) -> Self;
fn reverse_bits(self) -> Self;
fn rotate_left(self, n: u32) -> Self;
fn rotate_right(self, n: u32) -> Self;
fn saturating_add(self, rhs: Self) -> Self;
fn saturating_div(self, rhs: Self) -> Self;
fn saturating_mul(self, rhs: Self) -> Self;
fn saturating_pow(self, exp: u32) -> Self;
fn saturating_sub(self, rhs: Self) -> Self;
fn strict_add(self, rhs: Self) -> Self;
fn strict_div(self, rhs: Self) -> Self;
fn strict_div_euclid(self, rhs: Self) -> Self;
fn strict_mul(self, rhs: Self) -> Self;
fn strict_neg(self) -> Self;
fn strict_pow(self, exp: u32) -> Self;
fn strict_rem(self, rhs: Self) -> Self;
fn strict_rem_euclid(self, rhs: Self) -> Self;
fn strict_shl(self, rhs: u32) -> Self;
fn strict_shr(self, rhs: u32) -> Self;
fn strict_sub(self, rhs: Self) -> Self;
fn swap_bytes(self) -> Self;
fn to_be(self) -> Self;
fn to_le(self) -> Self;
fn trailing_ones(self) -> u32;
fn trailing_zeros(self) -> u32;
fn unbounded_shl(self, rhs: u32) -> Self;
fn unbounded_shr(self, rhs: u32) -> Self;
fn wrapping_add(self, rhs: Self) -> Self;
fn wrapping_div(self, rhs: Self) -> Self;
fn wrapping_div_euclid(self, rhs: Self) -> Self;
fn wrapping_mul(self, rhs: Self) -> Self;
fn wrapping_neg(self) -> Self;
fn wrapping_pow(self, exp: u32) -> Self;
fn wrapping_rem(self, rhs: Self) -> Self;
fn wrapping_rem_euclid(self, rhs: Self) -> Self;
fn wrapping_shl(self, rhs: u32) -> Self;
fn wrapping_shr(self, rhs: u32) -> Self;
fn wrapping_sub(self, rhs: Self) -> Self;
}
forward! {
unsafe fn unchecked_add(self, rhs: Self) -> Self;
unsafe fn unchecked_mul(self, rhs: Self) -> Self;
unsafe fn unchecked_shl(self, rhs: u32) -> Self;
unsafe fn unchecked_shr(self, rhs: u32) -> Self;
unsafe fn unchecked_sub(self, rhs: Self) -> Self;
}
}
impl PrimitiveIntegerRef<$Integer> for &$Integer {}
impl Sealed for NonZero<$Integer> {}
impl NonZeroPrimitiveInteger for NonZero<$Integer> {
type Integer = $Integer;
use_consts!(Self::{
BITS: u32,
MAX: Self,
MIN: Self,
});
forward! {
fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>;
fn new(n: Self::Integer) -> Option<Self>;
}
forward! {
fn checked_mul(self, other: Self) -> Option<Self>;
fn checked_pow(self, other: u32) -> Option<Self>;
fn count_ones(self) -> NonZero<u32>;
fn get(self) -> Self::Integer;
fn highest_one(self) -> u32;
fn isolate_highest_one(self) -> Self;
fn isolate_lowest_one(self) -> Self;
fn leading_zeros(self) -> u32;
fn lowest_one(self) -> u32;
fn saturating_mul(self, other: Self) -> Self;
fn saturating_pow(self, other: u32) -> Self;
fn trailing_zeros(self) -> u32;
}
forward! {
unsafe fn new_unchecked(n: Self::Integer) -> Self;
}
}
impl Sealed for NumBuffer<$Integer> {}
impl PrimitiveNumBuffer for NumBuffer<$Integer> {
forward! {
fn new() -> Self;
}
}
)*}
}
impl_integer!(i8, i16, i32, i64, i128, isize);
impl_integer!(u8, u16, u32, u64, u128, usize);