Trait surge_wavetable::imports::imports::AddAssign 1.8.0[−][src]
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
fn add_assign(&mut self, rhs: Rhs)
fn add_assign(&mut self, rhs: Rhs)
Implementations on Foreign Types
Implements the +=
operator for appending to a String
.
This has the same behavior as the push_str
method.
Implementors
impl<'a, A, S, S2, D, E> AddAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D> where
A: Clone + AddAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform self += rhs
as elementwise addition (in place).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
impl<A, S, D> AddAssign<A> for ArrayBase<S, D> where
A: ScalarOperand + AddAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
Perform self += rhs
as elementwise addition (in place).