Trait rug::ops::RemRoundingFrom

source ·
pub trait RemRoundingFrom<Lhs = Self> {
    // Required methods
    fn rem_trunc_from(&mut self, lhs: Lhs);
    fn rem_ceil_from(&mut self, lhs: Lhs);
    fn rem_floor_from(&mut self, lhs: Lhs);
    fn rem_euc_from(&mut self, lhs: Lhs);
}
Expand description

Compound assignment to the rhs operand and rounding variants of the remainder operation.

§Examples

use rug::ops::RemRoundingFrom;
struct I(i32);
impl RemRoundingFrom<i32> for I {
    fn rem_trunc_from(&mut self, lhs: i32) {
        self.0 = lhs % self.0;
    }
    fn rem_ceil_from(&mut self, lhs: i32) {
        let r = lhs % self.0;
        let change = if self.0 > 0 { r > 0 } else { r < 0 };
        self.0 = if change { r - self.0 } else { r };
    }
    fn rem_floor_from(&mut self, lhs: i32) {
        let r = lhs % self.0;
        let change = if self.0 > 0 { r < 0 } else { r > 0 };
        self.0 = if change { r + self.0 } else { r };
    }
    fn rem_euc_from(&mut self, lhs: i32) {
        let r = lhs % self.0;
        self.0 = if r < 0 {
            if self.0 < 0 {
                r - self.0
            } else {
                r + self.0
            }
        } else {
            r
        };
    }
}
let mut rem_ceil = I(3);
rem_ceil.rem_ceil_from(10);
assert_eq!(rem_ceil.0, -2);

Required Methods§

source

fn rem_trunc_from(&mut self, lhs: Lhs)

Finds the remainder when the quotient is rounded towards zero.

source

fn rem_ceil_from(&mut self, lhs: Lhs)

Finds the remainder when the quotient is rounded up.

source

fn rem_floor_from(&mut self, lhs: Lhs)

Finds the remainder when the quotient is rounded down.

source

fn rem_euc_from(&mut self, lhs: Lhs)

Finds the positive remainder from Euclidean division.

Implementations on Foreign Types§

source§

impl RemRoundingFrom for f32

source§

fn rem_trunc_from(&mut self, lhs: f32)

source§

fn rem_ceil_from(&mut self, lhs: f32)

source§

fn rem_floor_from(&mut self, lhs: f32)

source§

fn rem_euc_from(&mut self, lhs: f32)

source§

impl RemRoundingFrom for f64

source§

fn rem_trunc_from(&mut self, lhs: f64)

source§

fn rem_ceil_from(&mut self, lhs: f64)

source§

fn rem_floor_from(&mut self, lhs: f64)

source§

fn rem_euc_from(&mut self, lhs: f64)

source§

impl RemRoundingFrom for i8

source§

fn rem_trunc_from(&mut self, lhs: i8)

source§

fn rem_ceil_from(&mut self, lhs: i8)

source§

fn rem_floor_from(&mut self, lhs: i8)

source§

fn rem_euc_from(&mut self, lhs: i8)

source§

impl RemRoundingFrom for i16

source§

fn rem_trunc_from(&mut self, lhs: i16)

source§

fn rem_ceil_from(&mut self, lhs: i16)

source§

fn rem_floor_from(&mut self, lhs: i16)

source§

fn rem_euc_from(&mut self, lhs: i16)

source§

impl RemRoundingFrom for i32

source§

fn rem_trunc_from(&mut self, lhs: i32)

source§

fn rem_ceil_from(&mut self, lhs: i32)

source§

fn rem_floor_from(&mut self, lhs: i32)

source§

fn rem_euc_from(&mut self, lhs: i32)

source§

impl RemRoundingFrom for i64

source§

fn rem_trunc_from(&mut self, lhs: i64)

source§

fn rem_ceil_from(&mut self, lhs: i64)

source§

fn rem_floor_from(&mut self, lhs: i64)

source§

fn rem_euc_from(&mut self, lhs: i64)

source§

impl RemRoundingFrom for i128

source§

fn rem_trunc_from(&mut self, lhs: i128)

source§

fn rem_ceil_from(&mut self, lhs: i128)

source§

fn rem_floor_from(&mut self, lhs: i128)

source§

fn rem_euc_from(&mut self, lhs: i128)

source§

impl RemRoundingFrom for isize

source§

fn rem_trunc_from(&mut self, lhs: isize)

source§

fn rem_ceil_from(&mut self, lhs: isize)

source§

fn rem_floor_from(&mut self, lhs: isize)

source§

fn rem_euc_from(&mut self, lhs: isize)

source§

impl RemRoundingFrom<&f32> for f32

source§

fn rem_trunc_from(&mut self, lhs: &f32)

source§

fn rem_ceil_from(&mut self, lhs: &f32)

source§

fn rem_floor_from(&mut self, lhs: &f32)

source§

fn rem_euc_from(&mut self, lhs: &f32)

source§

impl RemRoundingFrom<&f64> for f64

source§

fn rem_trunc_from(&mut self, lhs: &f64)

source§

fn rem_ceil_from(&mut self, lhs: &f64)

source§

fn rem_floor_from(&mut self, lhs: &f64)

source§

fn rem_euc_from(&mut self, lhs: &f64)

source§

impl RemRoundingFrom<&i8> for i8

source§

fn rem_trunc_from(&mut self, lhs: &i8)

source§

fn rem_ceil_from(&mut self, lhs: &i8)

source§

fn rem_floor_from(&mut self, lhs: &i8)

source§

fn rem_euc_from(&mut self, lhs: &i8)

source§

impl RemRoundingFrom<&i16> for i16

source§

fn rem_trunc_from(&mut self, lhs: &i16)

source§

fn rem_ceil_from(&mut self, lhs: &i16)

source§

fn rem_floor_from(&mut self, lhs: &i16)

source§

fn rem_euc_from(&mut self, lhs: &i16)

source§

impl RemRoundingFrom<&i32> for i32

source§

fn rem_trunc_from(&mut self, lhs: &i32)

source§

fn rem_ceil_from(&mut self, lhs: &i32)

source§

fn rem_floor_from(&mut self, lhs: &i32)

source§

fn rem_euc_from(&mut self, lhs: &i32)

source§

impl RemRoundingFrom<&i64> for i64

source§

fn rem_trunc_from(&mut self, lhs: &i64)

source§

fn rem_ceil_from(&mut self, lhs: &i64)

source§

fn rem_floor_from(&mut self, lhs: &i64)

source§

fn rem_euc_from(&mut self, lhs: &i64)

source§

impl RemRoundingFrom<&i128> for i128

source§

fn rem_trunc_from(&mut self, lhs: &i128)

source§

fn rem_ceil_from(&mut self, lhs: &i128)

source§

fn rem_floor_from(&mut self, lhs: &i128)

source§

fn rem_euc_from(&mut self, lhs: &i128)

source§

impl RemRoundingFrom<&isize> for isize

source§

fn rem_trunc_from(&mut self, lhs: &isize)

source§

fn rem_ceil_from(&mut self, lhs: &isize)

source§

fn rem_floor_from(&mut self, lhs: &isize)

source§

fn rem_euc_from(&mut self, lhs: &isize)

Implementors§