Trait std::ops::SubStable
[-]
[+]
[src]
pub trait Sub<RHS = Self> {
type Output;
fn sub(self, rhs: RHS) -> <Self as Sub<RHS>>::Output;
}The Sub trait is used to specify the functionality of -.
Example
A trivial implementation of Sub. When Foo - Foo happens, it ends up
calling sub, and therefore, main prints Subtracting!.
#![feature(associated_types)] use std::ops::Sub; #[derive(Copy)] struct Foo; impl Sub for Foo { type Output = Foo; fn sub(self, _rhs: Foo) -> Foo { println!("Subtracting!"); self } } fn main() { Foo - Foo; }
Required Methods
Implementors
impl Sub<usize> for usizeimpl Sub<u8> for u8impl Sub<u16> for u16impl Sub<u32> for u32impl Sub<u64> for u64impl Sub<isize> for isizeimpl Sub<i8> for i8impl Sub<i16> for i16impl Sub<i32> for i32impl Sub<i64> for i64impl Sub<f32> for f32impl Sub<f64> for f64impl Sub for FilePermissionimpl Sub for Durationimpl<'a, 'b, T, S, H> Sub<&'b HashSet<T, S>> for &'a HashSet<T, S> where T: Eq + Hash<H> + Clone, S: HashState<Hasher=H> + Default, H: Hasher<Output=u64>impl<'a, 'b, T, S, H> Sub<&'b HashSet<T, S>> for &'a HashSet<T, S> where T: Eq + Hash<H> + Clone, S: HashState<Hasher=H> + Default, H: Hasher<Output=u64>impl<'a, 'b, T: Ord + Clone> Sub<&'b BTreeSet<T>> for &'a BTreeSet<T>impl<E: CLike> Sub<EnumSet<E>> for EnumSet<E>