Trait std::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<Wrapping<usize>> for Wrapping<usize>
impl Sub<Wrapping<u8>> for Wrapping<u8>
impl Sub<Wrapping<u16>> for Wrapping<u16>
impl Sub<Wrapping<u32>> for Wrapping<u32>
impl Sub<Wrapping<u64>> for Wrapping<u64>
impl Sub<Wrapping<isize>> for Wrapping<isize>
impl Sub<Wrapping<i8>> for Wrapping<i8>
impl Sub<Wrapping<i16>> for Wrapping<i16>
impl Sub<Wrapping<i32>> for Wrapping<i32>
impl Sub<Wrapping<i64>> for Wrapping<i64>
impl Sub<usize> 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<u8> 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<u16> 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<u32> 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<u64> 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<isize> 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<i8> 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<i16> 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<i32> 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<i64> 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<f32> 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<f64> 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
impl<'a, 'b, T> Sub<&'b BTreeSet<T>> for &'a BTreeSet<T> where T: Ord + Clone
impl<E> Sub<EnumSet<E>> for EnumSet<E> where E: CLike
impl<'a, 'b, T, S> Sub<&'b HashSet<T, S>> for &'a HashSet<T, S> where T: Eq + Hash + Clone, S: HashState + Default
impl Sub for Duration
impl Sub<Duration> for Instant
impl Sub<Duration> for SystemTime