Trait std::ops::AddStable
[-]
[+]
[src]
pub trait Add<RHS = Self> {
type Output;
fn add(self, rhs: RHS) -> <Self as Add<RHS>>::Output;
}The Add trait is used to specify the functionality of +.
Example
A trivial implementation of Add. When Foo + Foo happens, it ends up
calling add, and therefore, main prints Adding!.
#![feature(associated_types)] use std::ops::Add; #[derive(Copy)] struct Foo; impl Add for Foo { type Output = Foo; fn add(self, _rhs: Foo) -> Foo { println!("Adding!"); self } } fn main() { Foo + Foo; }
Required Methods
Implementors
impl Add<usize> for usizeimpl Add<u8> for u8impl Add<u16> for u16impl Add<u32> for u32impl Add<u64> for u64impl Add<isize> for isizeimpl Add<i8> for i8impl Add<i16> for i16impl Add<i32> for i32impl Add<i64> for i64impl Add<f32> for f32impl Add<f64> for f64impl Add for Durationimpl<'a> Add<&'a str> for Stringimpl<'a, T: Clone> Add<&'a [T]> for Vec<T>