Struct quickdiv::DivisorUsize
source · pub struct DivisorUsize { /* private fields */ }
Expand description
Faster divisor for division and modulo operations by pointer-sized unsigned integer values.
Implementations§
source§impl DivisorUsize
impl DivisorUsize
sourcepub const fn new(d: usize) -> DivisorUsize
pub const fn new(d: usize) -> DivisorUsize
sourcepub const fn get(&self) -> usize
pub const fn get(&self) -> usize
Returns the value that was used to construct this divisor as a primitive type.
Examples
use quickdiv::DivisorUsize;
let d = DivisorUsize::new(7);
assert_eq!(d.get(), 7);
sourcepub const fn divides(&self, n: usize) -> bool
pub const fn divides(&self, n: usize) -> bool
Returns true
if n
is divisible by self
.
We take 0
to be divisible by all non-zero numbers.
Examples
use quickdiv::DivisorUsize;
let d = DivisorUsize::new(17);
assert!(d.divides(34));
Trait Implementations§
source§impl Clone for DivisorUsize
impl Clone for DivisorUsize
source§fn clone(&self) -> DivisorUsize
fn clone(&self) -> DivisorUsize
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DivisorUsize
impl Debug for DivisorUsize
source§impl Div<DivisorUsize> for usize
impl Div<DivisorUsize> for usize
source§impl DivAssign<DivisorUsize> for usize
impl DivAssign<DivisorUsize> for usize
source§fn div_assign(&mut self, rhs: DivisorUsize)
fn div_assign(&mut self, rhs: DivisorUsize)
Performs the
/=
operation. Read moresource§impl Hash for DivisorUsize
impl Hash for DivisorUsize
source§impl PartialEq for DivisorUsize
impl PartialEq for DivisorUsize
source§fn eq(&self, other: &DivisorUsize) -> bool
fn eq(&self, other: &DivisorUsize) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Rem<DivisorUsize> for usize
impl Rem<DivisorUsize> for usize
source§impl RemAssign<DivisorUsize> for usize
impl RemAssign<DivisorUsize> for usize
source§fn rem_assign(&mut self, rhs: DivisorUsize)
fn rem_assign(&mut self, rhs: DivisorUsize)
Performs the
%=
operation. Read moreimpl Copy for DivisorUsize
impl Eq for DivisorUsize
impl StructuralEq for DivisorUsize
impl StructuralPartialEq for DivisorUsize
Auto Trait Implementations§
impl RefUnwindSafe for DivisorUsize
impl Send for DivisorUsize
impl Sync for DivisorUsize
impl Unpin for DivisorUsize
impl UnwindSafe for DivisorUsize
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more