Trait DivExact

Source
pub trait DivExact<RHS = Self> {
    type Output;

    // Required method
    fn div_exact(self, other: RHS) -> Self::Output;
}
Expand description

Divides two numbers, assuming the first exactly divides the second.

If it doesn’t, the div_exact function may panic or return a meaningless result.

Required Associated Types§

Required Methods§

Source

fn div_exact(self, other: RHS) -> Self::Output

Implementations on Foreign Types§

Source§

impl DivExact for i8

Source§

fn div_exact(self, other: i8) -> i8

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = i8

Source§

impl DivExact for i16

Source§

fn div_exact(self, other: i16) -> i16

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = i16

Source§

impl DivExact for i32

Source§

fn div_exact(self, other: i32) -> i32

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = i32

Source§

impl DivExact for i64

Source§

fn div_exact(self, other: i64) -> i64

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = i64

Source§

impl DivExact for i128

Source§

fn div_exact(self, other: i128) -> i128

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = i128

Source§

impl DivExact for isize

Source§

fn div_exact(self, other: isize) -> isize

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = isize

Source§

impl DivExact for u8

Source§

fn div_exact(self, other: u8) -> u8

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = u8

Source§

impl DivExact for u16

Source§

fn div_exact(self, other: u16) -> u16

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = u16

Source§

impl DivExact for u32

Source§

fn div_exact(self, other: u32) -> u32

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = u32

Source§

impl DivExact for u64

Source§

fn div_exact(self, other: u64) -> u64

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = u64

Source§

impl DivExact for u128

Source§

fn div_exact(self, other: u128) -> u128

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = u128

Source§

impl DivExact for usize

Source§

fn div_exact(self, other: usize) -> usize

Divides a value by another value. The first value must be exactly divisible by the second.

If self is not exactly divisible by other, this function may panic or return a meaningless result.

$$ f(x, y) = \frac{x}{y}. $$

If you are unsure whether the division will be exact, use self / other instead. If you’re unsure and you want to know, use self.div_mod(other) and check whether the remainder is zero. If you want a function that panics if the division is not exact, use self.div_round(other, Exact).

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if other is zero or if self is Self::MIN and other is -1.

§Examples

See here.

Source§

type Output = usize

Implementors§