1.8.0 · source ·
``````pub trait AddAssign<Rhs = Self> {
// Required method
}``````
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,
}

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§

source

#### fn add_assign(&mut self, rhs: Rhs)

Performs the `+=` operation.

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

## Implementors§

source§

source§

source§

source§

source§

source§

source§

source§

source§

source§

source§

source§

source§

source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

1.74.0 · source§

source§

source§

source§

source§

source§

source§

source§

source§

source§

source§

source§

source§

1.9.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.12.0 · source§

Implements the `+=` operator for appending to a `String`.

This has the same behavior as the `push_str` method.

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.22.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.74.0 · source§

1.60.0 · source§

1.9.0 · source§

1.9.0 · source§