Trait core::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; }
Associated Types
type Output
The resulting type after applying the +
operator
Required Methods
Implementors
impl Add for Wrapping<usize>
impl Add for Wrapping<u8>
impl Add for Wrapping<u16>
impl Add for Wrapping<u32>
impl Add for Wrapping<u64>
impl Add for Wrapping<isize>
impl Add for Wrapping<i8>
impl Add for Wrapping<i16>
impl Add for Wrapping<i32>
impl Add for Wrapping<i64>
impl Add for usize
impl<'a> Add<usize> for &'a usize
impl<'a> Add<&'a usize> for usize
impl<'a, 'b> Add<&'a usize> for &'b usize
impl Add for u8
impl<'a> Add<u8> for &'a u8
impl<'a> Add<&'a u8> for u8
impl<'a, 'b> Add<&'a u8> for &'b u8
impl Add for u16
impl<'a> Add<u16> for &'a u16
impl<'a> Add<&'a u16> for u16
impl<'a, 'b> Add<&'a u16> for &'b u16
impl Add for u32
impl<'a> Add<u32> for &'a u32
impl<'a> Add<&'a u32> for u32
impl<'a, 'b> Add<&'a u32> for &'b u32
impl Add for u64
impl<'a> Add<u64> for &'a u64
impl<'a> Add<&'a u64> for u64
impl<'a, 'b> Add<&'a u64> for &'b u64
impl Add for isize
impl<'a> Add<isize> for &'a isize
impl<'a> Add<&'a isize> for isize
impl<'a, 'b> Add<&'a isize> for &'b isize
impl Add for i8
impl<'a> Add<i8> for &'a i8
impl<'a> Add<&'a i8> for i8
impl<'a, 'b> Add<&'a i8> for &'b i8
impl Add for i16
impl<'a> Add<i16> for &'a i16
impl<'a> Add<&'a i16> for i16
impl<'a, 'b> Add<&'a i16> for &'b i16
impl Add for i32
impl<'a> Add<i32> for &'a i32
impl<'a> Add<&'a i32> for i32
impl<'a, 'b> Add<&'a i32> for &'b i32
impl Add for i64
impl<'a> Add<i64> for &'a i64
impl<'a> Add<&'a i64> for i64
impl<'a, 'b> Add<&'a i64> for &'b i64
impl Add for f32
impl<'a> Add<f32> for &'a f32
impl<'a> Add<&'a f32> for f32
impl<'a, 'b> Add<&'a f32> for &'b f32
impl Add for f64
impl<'a> Add<f64> for &'a f64
impl<'a> Add<&'a f64> for f64
impl<'a, 'b> Add<&'a f64> for &'b f64