Struct strength_reduce::StrengthReducedUsize
source · pub struct StrengthReducedUsize { /* private fields */ }
Expand description
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.
Implementations
sourceimpl StrengthReducedUsize
impl StrengthReducedUsize
sourcepub fn new(divisor: usize) -> Self
pub fn new(divisor: usize) -> Self
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
Trait Implementations
sourceimpl Clone for StrengthReducedUsize
impl Clone for StrengthReducedUsize
sourcefn clone(&self) -> StrengthReducedUsize
fn clone(&self) -> StrengthReducedUsize
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for StrengthReducedUsize
impl Debug for StrengthReducedUsize
sourceimpl Div<StrengthReducedUsize> for usize
impl Div<StrengthReducedUsize> for usize
sourceimpl Rem<StrengthReducedUsize> for usize
impl Rem<StrengthReducedUsize> for usize
impl Copy for StrengthReducedUsize
Auto Trait Implementations
impl RefUnwindSafe for StrengthReducedUsize
impl Send for StrengthReducedUsize
impl Sync for StrengthReducedUsize
impl Unpin for StrengthReducedUsize
impl UnwindSafe for StrengthReducedUsize
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more