Trait core::ops::Sub
[−]
[src]
pub trait Sub<RHS = Self> { type Output; fn sub(self, rhs: RHS) -> Self::Output; }
The Sub
trait is used to specify the functionality of -
.
Examples
A trivial implementation of Sub
. When Foo - Foo
happens, it ends up
calling sub
, and therefore, main
prints Subtracting!
.
use std::ops::Sub; #[derive(Copy, Clone)] struct Foo; impl Sub for Foo { type Output = Foo; fn sub(self, _rhs: Foo) -> Foo { println!("Subtracting!"); self } } fn main() { Foo - Foo; }
Associated Types
type Output
The resulting type after applying the -
operator
Required Methods
Implementors
impl Sub for Wrapping<usize>
impl Sub for Wrapping<u8>
impl Sub for Wrapping<u16>
impl Sub for Wrapping<u32>
impl Sub for Wrapping<u64>
impl Sub for Wrapping<isize>
impl Sub for Wrapping<i8>
impl Sub for Wrapping<i16>
impl Sub for Wrapping<i32>
impl Sub for Wrapping<i64>
impl Sub for usize
impl<'a> Sub<usize> for &'a usize
impl<'a> Sub<&'a usize> for usize
impl<'a, 'b> Sub<&'a usize> for &'b usize
impl Sub for u8
impl<'a> Sub<u8> for &'a u8
impl<'a> Sub<&'a u8> for u8
impl<'a, 'b> Sub<&'a u8> for &'b u8
impl Sub for u16
impl<'a> Sub<u16> for &'a u16
impl<'a> Sub<&'a u16> for u16
impl<'a, 'b> Sub<&'a u16> for &'b u16
impl Sub for u32
impl<'a> Sub<u32> for &'a u32
impl<'a> Sub<&'a u32> for u32
impl<'a, 'b> Sub<&'a u32> for &'b u32
impl Sub for u64
impl<'a> Sub<u64> for &'a u64
impl<'a> Sub<&'a u64> for u64
impl<'a, 'b> Sub<&'a u64> for &'b u64
impl Sub for isize
impl<'a> Sub<isize> for &'a isize
impl<'a> Sub<&'a isize> for isize
impl<'a, 'b> Sub<&'a isize> for &'b isize
impl Sub for i8
impl<'a> Sub<i8> for &'a i8
impl<'a> Sub<&'a i8> for i8
impl<'a, 'b> Sub<&'a i8> for &'b i8
impl Sub for i16
impl<'a> Sub<i16> for &'a i16
impl<'a> Sub<&'a i16> for i16
impl<'a, 'b> Sub<&'a i16> for &'b i16
impl Sub for i32
impl<'a> Sub<i32> for &'a i32
impl<'a> Sub<&'a i32> for i32
impl<'a, 'b> Sub<&'a i32> for &'b i32
impl Sub for i64
impl<'a> Sub<i64> for &'a i64
impl<'a> Sub<&'a i64> for i64
impl<'a, 'b> Sub<&'a i64> for &'b i64
impl Sub for f32
impl<'a> Sub<f32> for &'a f32
impl<'a> Sub<&'a f32> for f32
impl<'a, 'b> Sub<&'a f32> for &'b f32
impl Sub for f64
impl<'a> Sub<f64> for &'a f64
impl<'a> Sub<&'a f64> for f64
impl<'a, 'b> Sub<&'a f64> for &'b f64
impl Sub<u8x16> for u8x16
impl Sub<u16x8> for u16x8
impl Sub<u32x4> for u32x4
impl Sub<u64x2> for u64x2
impl Sub<i8x16> for i8x16
impl Sub<i16x8> for i16x8
impl Sub<i32x4> for i32x4
impl Sub<i64x2> for i64x2
impl Sub<f32x4> for f32x4
impl Sub<f64x2> for f64x2