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; #[derive(Copy, Clone)] 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<Wrapping<usize>> for Wrapping<usize>
impl Add<Wrapping<u8>> for Wrapping<u8>
impl Add<Wrapping<u16>> for Wrapping<u16>
impl Add<Wrapping<u32>> for Wrapping<u32>
impl Add<Wrapping<u64>> for Wrapping<u64>
impl Add<Wrapping<isize>> for Wrapping<isize>
impl Add<Wrapping<i8>> for Wrapping<i8>
impl Add<Wrapping<i16>> for Wrapping<i16>
impl Add<Wrapping<i32>> for Wrapping<i32>
impl Add<Wrapping<i64>> for Wrapping<i64>
impl Add<usize> 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<u8> 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<u16> 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<u32> 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<u64> 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<isize> 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<i8> 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<i16> 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<i32> 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<i64> 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<f32> 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<f64> 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
impl Add<u8x16> for u8x16
impl Add<u16x8> for u16x8
impl Add<u32x4> for u32x4
impl Add<u64x2> for u64x2
impl Add<i8x16> for i8x16
impl Add<i16x8> for i16x8
impl Add<i32x4> for i32x4
impl Add<i64x2> for i64x2
impl Add<f32x4> for f32x4
impl Add<f64x2> for f64x2
impl<'a> Add<&'a str> for String
impl Add for Duration
impl Add<Duration> for Instant
impl Add<Duration> for SystemTime