# Trait std::ops::Add [−] [src]

    pub trait Add<RHS = Self> {
        type Output;
        fn add(self, rhs: RHS) -> Self::Output;
    }

The `Add` trait is used to specify the functionality of `+`.

# Examples

A trivial implementation of `Add`. When `Foo + Foo` happens, it ends up calling `add`, and therefore, `main` prints `Adding!`.

use std::ops::Add; struct Foo; impl Add for Foo { type Output = Foo; fn add(self, _rhs: Foo) -> Foo { println!("Adding!"); self } } fn main() { Foo + Foo; }

    use std::ops::Add;

    struct Foo;

    impl Add for Foo {
        type Output = Foo;

        fn add(self, _rhs: Foo) -> Foo {
            println!("Adding!");
            self
        }
    }

    fn main() {
        Foo + Foo;
    }

## Associated Types

### `type Output`

The resulting type after applying the `+` operator

## Required Methods

### `fn add(self, rhs: RHS) -> Self::Output`

The method for the `+` operator

## Implementors

- `impl<'a, 'b> Add<&'a f64> for &'b f64`
- `impl<'a> Add<&'a f64> for f64`
- `impl<'a> Add<f64> for &'a f64`
- `impl Add<f64> for f64`
- `impl<'a, 'b> Add<&'a f32> for &'b f32`
- `impl<'a> Add<&'a f32> for f32`
- `impl<'a> Add<f32> for &'a f32`
- `impl Add<f32> for f32`
- `impl<'a, 'b> Add<&'a i64> for &'b i64`
- `impl<'a> Add<&'a i64> for i64`
- `impl<'a> Add<i64> for &'a i64`
- `impl Add<i64> for i64`
- `impl<'a, 'b> Add<&'a i32> for &'b i32`
- `impl<'a> Add<&'a i32> for i32`
- `impl<'a> Add<i32> for &'a i32`
- `impl Add<i32> for i32`
- `impl<'a, 'b> Add<&'a i16> for &'b i16`
- `impl<'a> Add<&'a i16> for i16`
- `impl<'a> Add<i16> for &'a i16`
- `impl Add<i16> for i16`
- `impl<'a, 'b> Add<&'a i8> for &'b i8`
- `impl<'a> Add<&'a i8> for i8`
- `impl<'a> Add<i8> for &'a i8`
- `impl Add<i8> for i8`
- `impl<'a, 'b> Add<&'a isize> for &'b isize`
- `impl<'a> Add<&'a isize> for isize`
- `impl<'a> Add<isize> for &'a isize`
- `impl Add<isize> for isize`
- `impl<'a, 'b> Add<&'a u64> for &'b u64`
- `impl<'a> Add<&'a u64> for u64`
- `impl<'a> Add<u64> for &'a u64`
- `impl Add<u64> for u64`
- `impl<'a, 'b> Add<&'a u32> for &'b u32`
- `impl<'a> Add<&'a u32> for u32`
- `impl<'a> Add<u32> for &'a u32`
- `impl Add<u32> for u32`
- `impl<'a, 'b> Add<&'a u16> for &'b u16`
- `impl<'a> Add<&'a u16> for u16`
- `impl<'a> Add<u16> for &'a u16`
- `impl Add<u16> for u16`
- `impl<'a, 'b> Add<&'a u8> for &'b u8`
- `impl<'a> Add<&'a u8> for u8`
- `impl<'a> Add<u8> for &'a u8`
- `impl Add<u8> for u8`
- `impl<'a, 'b> Add<&'a usize> for &'b usize`
- `impl<'a> Add<&'a usize> for usize`
- `impl<'a> Add<usize> for &'a usize`
- `impl Add<usize> for usize`
- `impl<'a> Add<&'a str> for String`
- `impl Add<Wrapping<i64>> for Wrapping<i64>`
- `impl Add<Wrapping<i32>> for Wrapping<i32>`
- `impl Add<Wrapping<i16>> for Wrapping<i16>`
- `impl Add<Wrapping<i8>> for Wrapping<i8>`
- `impl Add<Wrapping<isize>> for Wrapping<isize>`
- `impl Add<Wrapping<u64>> for Wrapping<u64>`
- `impl Add<Wrapping<u32>> for Wrapping<u32>`
- `impl Add<Wrapping<u16>> for Wrapping<u16>`
- `impl Add<Wrapping<u8>> for Wrapping<u8>`
- `impl Add<Wrapping<usize>> for Wrapping<usize>`
- `impl Add for Duration`
- `impl Add<Duration> for Instant`
- `impl Add<Duration> for SystemTime`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)