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