Trait sp_std::ops::AddAssign

1.8.0 · source · []
pub trait AddAssign<Rhs = Self> {
    fn add_assign(&mut self, rhs: Rhs);
}
Expand description

The addition assignment operator +=.

Examples

This example creates a Point struct that implements the AddAssign trait, and then demonstrates add-assigning to a mutable Point.

use std::ops::AddAssign;

#[derive(Debug, Copy, Clone, PartialEq)]
struct Point {
    x: i32,
    y: i32,
}

impl AddAssign for Point {
    fn add_assign(&mut self, other: Self) {
        *self = Self {
            x: self.x + other.x,
            y: self.y + other.y,
        };
    }
}

let mut point = Point { x: 1, y: 0 };
point += Point { x: 2, y: 3 };
assert_eq!(point, Point { x: 3, y: 3 });

Required methods

Performs the += operation.

Example
let mut x: u32 = 12;
x += 1;
assert_eq!(x, 13);

Implementations on Foreign Types

Implements the += operator for appending to a String.

This has the same behavior as the push_str method.

Implementors

impl<'b> AddAssign<&'b Scalar> for Scalar

impl<'b, T, R1, C1, R2, C2, SA, SB> AddAssign<&'b Matrix<T, R2, C2, SB>> for Matrix<T, R1, C1, SA> where
    R1: Dim,
    C1: Dim,
    R2: Dim,
    C2: Dim,
    T: Scalar + ClosedAdd,
    SA: StorageMut<T, R1, C1>,
    SB: Storage<T, R2, C2>,
    ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2>, 

impl<T, R1, C1, R2, C2, SA, SB> AddAssign<Matrix<T, R2, C2, SB>> for Matrix<T, R1, C1, SA> where
    R1: Dim,
    C1: Dim,
    R2: Dim,
    C2: Dim,
    T: Scalar + ClosedAdd,
    SA: StorageMut<T, R1, C1>,
    SB: Storage<T, R2, C2>,
    ShapeConstraint: SameNumberOfRows<R1, R2> + SameNumberOfColumns<C1, C2>, 

impl<'b, T, D2: Dim, SB, const D1: usize> AddAssign<&'b Matrix<T, D2, Const<1_usize>, SB>> for Point<T, D1> where
    T: Scalar + ClosedAdd,
    SB: Storage<T, D2>,
    ShapeConstraint: SameNumberOfRows<Const<D1>, D2>, 

impl<T, D2: Dim, SB, const D1: usize> AddAssign<Matrix<T, D2, Const<1_usize>, SB>> for Point<T, D1> where
    T: Scalar + ClosedAdd,
    SB: Storage<T, D2>,
    ShapeConstraint: SameNumberOfRows<Const<D1>, D2>, 

impl<'b, T: SimdRealField> AddAssign<&'b Quaternion<T>> for Quaternion<T> where
    T::Element: SimdRealField

impl<T: SimdRealField> AddAssign<Quaternion<T>> for Quaternion<T> where
    T::Element: SimdRealField

impl<'b, T: SimdRealField> AddAssign<&'b DualQuaternion<T>> for DualQuaternion<T> where
    T::Element: SimdRealField

impl<'a> AddAssign<&'a BigInt> for BigInt

impl AddAssign<u8> for BigInt

impl AddAssign<u16> for BigInt

impl AddAssign<i8> for BigInt

impl AddAssign<i16> for BigInt

impl AddAssign<u32> for BigInt

impl AddAssign<u64> for BigInt

impl AddAssign<i32> for BigInt

impl AddAssign<i64> for BigInt

impl<'a> AddAssign<&'a BigUint> for BigUint

impl AddAssign<u8> for BigUint

impl<T: Clone + NumAssign> AddAssign<Complex<T>> for Complex<T>

impl<T: Clone + NumAssign> AddAssign<T> for Complex<T>

impl<'a, T: Clone + NumAssign> AddAssign<&'a Complex<T>> for Complex<T>

impl<'a, T: Clone + NumAssign> AddAssign<&'a T> for Complex<T>

impl<T: Clone + Integer + NumAssign> AddAssign<Ratio<T>> for Ratio<T>

impl<T: Clone + Integer + NumAssign> AddAssign<T> for Ratio<T>

impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a Ratio<T>> for Ratio<T>

impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a T> for Ratio<T>

impl AddAssign<U128> for U128

impl AddAssign<U256> for U256

impl AddAssign<U512> for U512

impl<'a> AddAssign<&'a Field> for Field

impl<'a> AddAssign<&'a Scalar> for Scalar