pub trait Counter:
Default
+ Sized
+ From<u8>
+ TryFrom<u32>
+ TryFrom<usize> {
// Required methods
fn checked_add_assign(&mut self, rhs: Self) -> Result<(), Overflowed>;
fn checked_mul(self, rhs: Self) -> Result<Self, Overflowed>;
fn byte_aligned(&self) -> bool;
}
Expand description
A common trait for integer types for performing math operations which may check for overflow.
Required Methods§
Sourcefn checked_add_assign(&mut self, rhs: Self) -> Result<(), Overflowed>
fn checked_add_assign(&mut self, rhs: Self) -> Result<(), Overflowed>
add rhs to self, returning Overflowed
if the result is too large
Sourcefn checked_mul(self, rhs: Self) -> Result<Self, Overflowed>
fn checked_mul(self, rhs: Self) -> Result<Self, Overflowed>
multiply self by rhs, returning Overflowed
if the result is too large
Sourcefn byte_aligned(&self) -> bool
fn byte_aligned(&self) -> bool
returns true
if the number if bits written is divisible by 8
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.