pub trait SubAssign<Rhs = Self> {
fn sub_assign(&mut self, rhs: Rhs);
}
Expand description
The subtraction assignment operator -=
.
This example creates a Point
struct that implements the SubAssign
trait, and then demonstrates sub-assigning to a mutable Point
.
use std::ops::SubAssign;
#[derive(Debug, Copy, Clone, PartialEq)]
struct Point {
x: i32,
y: i32,
}
impl SubAssign for Point {
fn sub_assign(&mut self, other: Self) {
*self = Self {
x: self.x - other.x,
y: self.y - other.y,
};
}
}
let mut point = Point { x: 3, y: 3 };
point -= Point { x: 2, y: 3 };
assert_eq!(point, Point {x: 1, y: 0});
Performs the -=
operation.
let mut x: u32 = 12;
x -= 1;
assert_eq!(x, 11);
impl<'a, P> SubAssign<&'a Fp2<P>> for Fp2<P> where
P: Fp2Parameters,
impl<'a, P> SubAssign<&'a Fp6<P>> for Fp6<P> where
P: Fp6Parameters,
impl<'a, P> SubAssign<&'a Fp12<P>> for Fp12<P> where
P: Fp12Parameters,
impl<'a, P> SubAssign<&'a Fp256<P>> for Fp256<P> where
P: Fp256Parameters,
impl<'a, P> SubAssign<&'a Fp384<P>> for Fp384<P> where
P: Fp384Parameters,
impl<'a, P> SubAssign<&'a Projective<P>> for Projective<P> where
P: ShortWeierstrassParameters,
impl<'a, P> SubAssign<&'a Projective<P>> for Projective<P> where
P: TwistedEdwardsParameters,
impl<'a, P> SubAssign<&'a mut Fp2<P>> for Fp2<P> where
P: Fp2Parameters,
impl<'a, P> SubAssign<&'a mut Fp6<P>> for Fp6<P> where
P: Fp6Parameters,
impl<'a, P> SubAssign<&'a mut Fp12<P>> for Fp12<P> where
P: Fp12Parameters,
impl<'a, P> SubAssign<&'a mut Fp256<P>> for Fp256<P> where
P: Fp256Parameters,
impl<'a, P> SubAssign<&'a mut Fp384<P>> for Fp384<P> where
P: Fp384Parameters,
impl<'a, P> SubAssign<&'a mut Projective<P>> for Projective<P> where
P: ShortWeierstrassParameters,
impl<'a, P> SubAssign<&'a mut Projective<P>> for Projective<P> where
P: TwistedEdwardsParameters,
impl<E> SubAssign<&Field<E>> for Field<E> where
E: Environment,
impl<E> SubAssign<&Group<E>> for Group<E> where
E: Environment,
impl<E> SubAssign<&Scalar<E>> for Scalar<E> where
E: Environment,
impl<E> SubAssign<Field<E>> for Field<E> where
E: Environment,
impl<E> SubAssign<Group<E>> for Group<E> where
E: Environment,
impl<E> SubAssign<Scalar<E>> for Scalar<E> where
E: Environment,
impl<P> SubAssign<&&Fp2<P>> for Fp2<P> where
P: Fp2Parameters,
impl<P> SubAssign<&&Fp6<P>> for Fp6<P> where
P: Fp6Parameters,
impl<P> SubAssign<&&Fp12<P>> for Fp12<P> where
P: Fp12Parameters,
impl<P> SubAssign<&&Fp256<P>> for Fp256<P> where
P: Fp256Parameters,
impl<P> SubAssign<&&Fp384<P>> for Fp384<P> where
P: Fp384Parameters,
impl<P> SubAssign<&&Projective<P>> for Projective<P> where
P: ShortWeierstrassParameters,
impl<P> SubAssign<&&Projective<P>> for Projective<P> where
P: TwistedEdwardsParameters,
impl<P> SubAssign<Fp2<P>> for Fp2<P> where
P: Fp2Parameters,
impl<P> SubAssign<Fp6<P>> for Fp6<P> where
P: Fp6Parameters,
impl<P> SubAssign<Fp12<P>> for Fp12<P> where
P: Fp12Parameters,
impl<P> SubAssign<Fp256<P>> for Fp256<P> where
P: Fp256Parameters,
impl<P> SubAssign<Fp384<P>> for Fp384<P> where
P: Fp384Parameters,
impl<P> SubAssign<Projective<P>> for Projective<P> where
P: ShortWeierstrassParameters,
impl<P> SubAssign<Projective<P>> for Projective<P> where
P: TwistedEdwardsParameters,