[−][src]Struct strength_reduce::StrengthReducedU8
Implements unsigned division and modulo via mutiplication and shifts.
Creating a an instance of this struct is more expensive than a single division, but if the division is repeated, this version will be several times faster than naive division.
Methods
impl StrengthReducedU8
[src]
pub fn new(divisor: u8) -> Self
[src]
Creates a new divisor instance.
If possible, avoid calling new() from an inner loop: The intended usage is to create an instance of this struct outside the loop, and use it for divison and remainders inside the loop.
Panics:
Panics if divisor
is 0
pub fn div_rem(numerator: u8, denom: Self) -> (u8, u8)
[src]
Simultaneous truncated integer division and modulus.
Returns (quotient, remainder)
.
pub fn get(&self) -> u8
[src]
Retrieve the value used to create this struct
Trait Implementations
impl Clone for StrengthReducedU8
[src]
fn clone(&self) -> StrengthReducedU8
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for StrengthReducedU8
[src]
impl Debug for StrengthReducedU8
[src]
impl Div<StrengthReducedU8> for u8
[src]
type Output = u8
The resulting type after applying the /
operator.
fn div(self, rhs: StrengthReducedU8) -> Self::Output
[src]
impl Rem<StrengthReducedU8> for u8
[src]
type Output = u8
The resulting type after applying the %
operator.
fn rem(self, rhs: StrengthReducedU8) -> Self::Output
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,