pub trait Int: Clone + Copy + Debug + Default + Display + Eq + FromStr + Hash + Ord + IntConv + IntOps {
type Signed: IntSigned;
type Unsigned: IntUnsigned;
Show 13 associated constants and 15 methods
const BITS: u32;
const ZERO: Self;
const ONE: Self;
const TWO: Self;
const THREE: Self;
const FOUR: Self;
const FIVE: Self;
const SIX: Self;
const SEVEN: Self;
const EIGHT: Self;
const NINE: Self;
const MIN: Self;
const MAX: Self;
// Required methods
fn unsigned_abs(self) -> Self::Unsigned;
fn signum(self) -> Self::Signed;
fn signed_diff(self, other: Self) -> NumResult<Self::Signed>;
fn unsigned_diff(self, other: Self) -> NumResult<Self::Unsigned>;
fn add_signed(self, other: Self::Signed) -> NumResult<Self>;
fn sub_signed(self, other: Self::Signed) -> NumResult<Self>;
fn gen_count_ones(self) -> u32;
// Provided methods
fn check_bit(self, bit: u32) -> bool { ... }
fn bit_set_assign(&mut self, bit: u32) { ... }
fn bit_clear_assign(&mut self, bit: u32) { ... }
fn bound_start_assign(&mut self, other: Self) { ... }
fn bound_end_assign(&mut self, other: Self) { ... }
fn bounds_assign(&mut self, bounds: impl RangeBounds<Self>) { ... }
fn lcm(num_0: Self, num_1: Self) -> Self { ... }
fn gcd(num_0: Self, num_1: Self) -> Self { ... }
}
Required Associated Types§
Required Associated Constants§
const BITS: u32
const ZERO: Self
const ONE: Self
const TWO: Self
const THREE: Self
const FOUR: Self
const FIVE: Self
const SIX: Self
const SEVEN: Self
const EIGHT: Self
const NINE: Self
const MIN: Self
const MAX: Self
Required Methods§
fn unsigned_abs(self) -> Self::Unsigned
fn signum(self) -> Self::Signed
sourcefn signed_diff(self, other: Self) -> NumResult<Self::Signed>
fn signed_diff(self, other: Self) -> NumResult<Self::Signed>
Signed difference between two numbers
Errors
Returns Err (Overflow)
if the result can’t be represented, ie if the difference is too
high
sourcefn unsigned_diff(self, other: Self) -> NumResult<Self::Unsigned>
fn unsigned_diff(self, other: Self) -> NumResult<Self::Unsigned>
Unsigned difference between two numbers
Errors
Returns Err (Overflow)
if the result can’t be represented, ie if the second number is
greater than the first
sourcefn add_signed(self, other: Self::Signed) -> NumResult<Self>
fn add_signed(self, other: Self::Signed) -> NumResult<Self>
sourcefn sub_signed(self, other: Self::Signed) -> NumResult<Self>
fn sub_signed(self, other: Self::Signed) -> NumResult<Self>
sourcefn gen_count_ones(self) -> u32
fn gen_count_ones(self) -> u32
Generic wrapper for primitive count_ones
function.