pub trait UnsignedInt: Integer {
// Required methods
fn checked_next_power_of_two(self) -> Option<Self>;
fn is_power_of_two(self) -> bool;
fn next_power_of_two(self) -> Self;
// Provided methods
fn is_non_negative(self) -> bool { ... }
fn abs(self) -> Self
where Self: Sized { ... }
}Expand description
A trait for unsigned integer types.
Extends Integer with operations and guarantees specific to unsigned types.
§Mathematical Background
Unsigned integers represent $\mathbb{N}_0$ (natural numbers including zero) within a bounded range. They do NOT form an additive group under standard arithmetic since subtraction can produce values outside the representable range (negative numbers).
Under modular/wrapping arithmetic, they form $\mathbb{Z}/2^n\mathbb{Z}$, a ring.
Required Methods§
Sourcefn checked_next_power_of_two(self) -> Option<Self>
fn checked_next_power_of_two(self) -> Option<Self>
Returns the next power of two greater than or equal to self.
Returns None if the result would overflow.
Sourcefn is_power_of_two(self) -> bool
fn is_power_of_two(self) -> bool
Returns true if self is a power of two.
Sourcefn next_power_of_two(self) -> Self
fn next_power_of_two(self) -> Self
Returns the smallest power of two greater than or equal to self.
§Panics
Panics if the result would overflow.
Provided Methods§
Sourcefn is_non_negative(self) -> bool
fn is_non_negative(self) -> bool
Returns true. Provided for API consistency with SignedInt.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.