Trait elliptic_curve::ops::Sub
1.0.0 · source · [−]Expand description
The subtraction operator -
.
Note that Rhs
is Self
by default, but this is not mandatory. For
example, std::time::SystemTime
implements Sub<Duration>
, which permits
operations of the form SystemTime = SystemTime - Duration
.
Examples
Sub
tractable points
use std::ops::Sub;
#[derive(Debug, Copy, Clone, PartialEq)]
struct Point {
x: i32,
y: i32,
}
impl Sub for Point {
type Output = Self;
fn sub(self, other: Self) -> Self::Output {
Self {
x: self.x - other.x,
y: self.y - other.y,
}
}
}
assert_eq!(Point { x: 3, y: 3 } - Point { x: 2, y: 3 },
Point { x: 1, y: 0 });
Implementing Sub
with generics
Here is an example of the same Point
struct implementing the Sub
trait
using generics.
use std::ops::Sub;
#[derive(Debug, PartialEq)]
struct Point<T> {
x: T,
y: T,
}
// Notice that the implementation uses the associated type `Output`.
impl<T: Sub<Output = T>> Sub for Point<T> {
type Output = Self;
fn sub(self, other: Self) -> Self::Output {
Point {
x: self.x - other.x,
y: self.y - other.y,
}
}
}
assert_eq!(Point { x: 2, y: 3 } - Point { x: 1, y: 0 },
Point { x: 1, y: 3 });
Required Associated Types
Required Methods
Implementors
sourceimpl Sub<&Saturating<i8>> for &Saturating<i8>
impl Sub<&Saturating<i8>> for &Saturating<i8>
type Output = <Saturating<i8> as Sub<Saturating<i8>>>::Output
sourceimpl Sub<&Saturating<i8>> for Saturating<i8>
impl Sub<&Saturating<i8>> for Saturating<i8>
type Output = <Saturating<i8> as Sub<Saturating<i8>>>::Output
sourceimpl Sub<&Saturating<i16>> for &Saturating<i16>
impl Sub<&Saturating<i16>> for &Saturating<i16>
type Output = <Saturating<i16> as Sub<Saturating<i16>>>::Output
sourceimpl Sub<&Saturating<i16>> for Saturating<i16>
impl Sub<&Saturating<i16>> for Saturating<i16>
type Output = <Saturating<i16> as Sub<Saturating<i16>>>::Output
sourceimpl Sub<&Saturating<i32>> for &Saturating<i32>
impl Sub<&Saturating<i32>> for &Saturating<i32>
type Output = <Saturating<i32> as Sub<Saturating<i32>>>::Output
sourceimpl Sub<&Saturating<i32>> for Saturating<i32>
impl Sub<&Saturating<i32>> for Saturating<i32>
type Output = <Saturating<i32> as Sub<Saturating<i32>>>::Output
sourceimpl Sub<&Saturating<i64>> for &Saturating<i64>
impl Sub<&Saturating<i64>> for &Saturating<i64>
type Output = <Saturating<i64> as Sub<Saturating<i64>>>::Output
sourceimpl Sub<&Saturating<i64>> for Saturating<i64>
impl Sub<&Saturating<i64>> for Saturating<i64>
type Output = <Saturating<i64> as Sub<Saturating<i64>>>::Output
sourceimpl Sub<&Saturating<i128>> for &Saturating<i128>
impl Sub<&Saturating<i128>> for &Saturating<i128>
type Output = <Saturating<i128> as Sub<Saturating<i128>>>::Output
sourceimpl Sub<&Saturating<i128>> for Saturating<i128>
impl Sub<&Saturating<i128>> for Saturating<i128>
type Output = <Saturating<i128> as Sub<Saturating<i128>>>::Output
sourceimpl Sub<&Saturating<isize>> for &Saturating<isize>
impl Sub<&Saturating<isize>> for &Saturating<isize>
type Output = <Saturating<isize> as Sub<Saturating<isize>>>::Output
sourceimpl Sub<&Saturating<isize>> for Saturating<isize>
impl Sub<&Saturating<isize>> for Saturating<isize>
type Output = <Saturating<isize> as Sub<Saturating<isize>>>::Output
sourceimpl Sub<&Saturating<u8>> for &Saturating<u8>
impl Sub<&Saturating<u8>> for &Saturating<u8>
type Output = <Saturating<u8> as Sub<Saturating<u8>>>::Output
sourceimpl Sub<&Saturating<u8>> for Saturating<u8>
impl Sub<&Saturating<u8>> for Saturating<u8>
type Output = <Saturating<u8> as Sub<Saturating<u8>>>::Output
sourceimpl Sub<&Saturating<u16>> for &Saturating<u16>
impl Sub<&Saturating<u16>> for &Saturating<u16>
type Output = <Saturating<u16> as Sub<Saturating<u16>>>::Output
sourceimpl Sub<&Saturating<u16>> for Saturating<u16>
impl Sub<&Saturating<u16>> for Saturating<u16>
type Output = <Saturating<u16> as Sub<Saturating<u16>>>::Output
sourceimpl Sub<&Saturating<u32>> for &Saturating<u32>
impl Sub<&Saturating<u32>> for &Saturating<u32>
type Output = <Saturating<u32> as Sub<Saturating<u32>>>::Output
sourceimpl Sub<&Saturating<u32>> for Saturating<u32>
impl Sub<&Saturating<u32>> for Saturating<u32>
type Output = <Saturating<u32> as Sub<Saturating<u32>>>::Output
sourceimpl Sub<&Saturating<u64>> for &Saturating<u64>
impl Sub<&Saturating<u64>> for &Saturating<u64>
type Output = <Saturating<u64> as Sub<Saturating<u64>>>::Output
sourceimpl Sub<&Saturating<u64>> for Saturating<u64>
impl Sub<&Saturating<u64>> for Saturating<u64>
type Output = <Saturating<u64> as Sub<Saturating<u64>>>::Output
sourceimpl Sub<&Saturating<u128>> for &Saturating<u128>
impl Sub<&Saturating<u128>> for &Saturating<u128>
type Output = <Saturating<u128> as Sub<Saturating<u128>>>::Output
sourceimpl Sub<&Saturating<u128>> for Saturating<u128>
impl Sub<&Saturating<u128>> for Saturating<u128>
type Output = <Saturating<u128> as Sub<Saturating<u128>>>::Output
sourceimpl Sub<&Saturating<usize>> for &Saturating<usize>
impl Sub<&Saturating<usize>> for &Saturating<usize>
type Output = <Saturating<usize> as Sub<Saturating<usize>>>::Output
sourceimpl Sub<&Saturating<usize>> for Saturating<usize>
impl Sub<&Saturating<usize>> for Saturating<usize>
type Output = <Saturating<usize> as Sub<Saturating<usize>>>::Output
1.14.0 (const: unstable) · sourceimpl Sub<&Wrapping<isize>> for &core::num::wrapping::Wrapping<isize>
impl Sub<&Wrapping<isize>> for &core::num::wrapping::Wrapping<isize>
1.14.0 (const: unstable) · sourceimpl Sub<&Wrapping<isize>> for core::num::wrapping::Wrapping<isize>
impl Sub<&Wrapping<isize>> for core::num::wrapping::Wrapping<isize>
1.14.0 (const: unstable) · sourceimpl Sub<&Wrapping<usize>> for &core::num::wrapping::Wrapping<usize>
impl Sub<&Wrapping<usize>> for &core::num::wrapping::Wrapping<usize>
1.14.0 (const: unstable) · sourceimpl Sub<&Wrapping<usize>> for core::num::wrapping::Wrapping<usize>
impl Sub<&Wrapping<usize>> for core::num::wrapping::Wrapping<usize>
sourceimpl Sub<Saturating<i8>> for Saturating<i8>
impl Sub<Saturating<i8>> for Saturating<i8>
type Output = Saturating<i8>
sourceimpl Sub<Saturating<i16>> for Saturating<i16>
impl Sub<Saturating<i16>> for Saturating<i16>
type Output = Saturating<i16>
sourceimpl Sub<Saturating<i32>> for Saturating<i32>
impl Sub<Saturating<i32>> for Saturating<i32>
type Output = Saturating<i32>
sourceimpl Sub<Saturating<i64>> for Saturating<i64>
impl Sub<Saturating<i64>> for Saturating<i64>
type Output = Saturating<i64>
sourceimpl Sub<Saturating<i128>> for Saturating<i128>
impl Sub<Saturating<i128>> for Saturating<i128>
type Output = Saturating<i128>
sourceimpl Sub<Saturating<isize>> for Saturating<isize>
impl Sub<Saturating<isize>> for Saturating<isize>
type Output = Saturating<isize>
sourceimpl Sub<Saturating<u8>> for Saturating<u8>
impl Sub<Saturating<u8>> for Saturating<u8>
type Output = Saturating<u8>
sourceimpl Sub<Saturating<u16>> for Saturating<u16>
impl Sub<Saturating<u16>> for Saturating<u16>
type Output = Saturating<u16>
sourceimpl Sub<Saturating<u32>> for Saturating<u32>
impl Sub<Saturating<u32>> for Saturating<u32>
type Output = Saturating<u32>
sourceimpl Sub<Saturating<u64>> for Saturating<u64>
impl Sub<Saturating<u64>> for Saturating<u64>
type Output = Saturating<u64>
sourceimpl Sub<Saturating<u128>> for Saturating<u128>
impl Sub<Saturating<u128>> for Saturating<u128>
type Output = Saturating<u128>
sourceimpl Sub<Saturating<usize>> for Saturating<usize>
impl Sub<Saturating<usize>> for Saturating<usize>
type Output = Saturating<usize>
1.8.0 · sourceimpl Sub<Duration> for SystemTime
impl Sub<Duration> for SystemTime
type Output = SystemTime
sourceimpl<'a> Sub<Saturating<i8>> for &'a Saturating<i8>
impl<'a> Sub<Saturating<i8>> for &'a Saturating<i8>
type Output = <Saturating<i8> as Sub<Saturating<i8>>>::Output
sourceimpl<'a> Sub<Saturating<i16>> for &'a Saturating<i16>
impl<'a> Sub<Saturating<i16>> for &'a Saturating<i16>
type Output = <Saturating<i16> as Sub<Saturating<i16>>>::Output
sourceimpl<'a> Sub<Saturating<i32>> for &'a Saturating<i32>
impl<'a> Sub<Saturating<i32>> for &'a Saturating<i32>
type Output = <Saturating<i32> as Sub<Saturating<i32>>>::Output
sourceimpl<'a> Sub<Saturating<i64>> for &'a Saturating<i64>
impl<'a> Sub<Saturating<i64>> for &'a Saturating<i64>
type Output = <Saturating<i64> as Sub<Saturating<i64>>>::Output
sourceimpl<'a> Sub<Saturating<i128>> for &'a Saturating<i128>
impl<'a> Sub<Saturating<i128>> for &'a Saturating<i128>
type Output = <Saturating<i128> as Sub<Saturating<i128>>>::Output
sourceimpl<'a> Sub<Saturating<isize>> for &'a Saturating<isize>
impl<'a> Sub<Saturating<isize>> for &'a Saturating<isize>
type Output = <Saturating<isize> as Sub<Saturating<isize>>>::Output
sourceimpl<'a> Sub<Saturating<u8>> for &'a Saturating<u8>
impl<'a> Sub<Saturating<u8>> for &'a Saturating<u8>
type Output = <Saturating<u8> as Sub<Saturating<u8>>>::Output
sourceimpl<'a> Sub<Saturating<u16>> for &'a Saturating<u16>
impl<'a> Sub<Saturating<u16>> for &'a Saturating<u16>
type Output = <Saturating<u16> as Sub<Saturating<u16>>>::Output
sourceimpl<'a> Sub<Saturating<u32>> for &'a Saturating<u32>
impl<'a> Sub<Saturating<u32>> for &'a Saturating<u32>
type Output = <Saturating<u32> as Sub<Saturating<u32>>>::Output
sourceimpl<'a> Sub<Saturating<u64>> for &'a Saturating<u64>
impl<'a> Sub<Saturating<u64>> for &'a Saturating<u64>
type Output = <Saturating<u64> as Sub<Saturating<u64>>>::Output
sourceimpl<'a> Sub<Saturating<u128>> for &'a Saturating<u128>
impl<'a> Sub<Saturating<u128>> for &'a Saturating<u128>
type Output = <Saturating<u128> as Sub<Saturating<u128>>>::Output
sourceimpl<'a> Sub<Saturating<usize>> for &'a Saturating<usize>
impl<'a> Sub<Saturating<usize>> for &'a Saturating<usize>
type Output = <Saturating<usize> as Sub<Saturating<usize>>>::Output
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<i8>> for &'a core::num::wrapping::Wrapping<i8>
impl<'a> Sub<Wrapping<i8>> for &'a core::num::wrapping::Wrapping<i8>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<i16>> for &'a core::num::wrapping::Wrapping<i16>
impl<'a> Sub<Wrapping<i16>> for &'a core::num::wrapping::Wrapping<i16>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<i32>> for &'a core::num::wrapping::Wrapping<i32>
impl<'a> Sub<Wrapping<i32>> for &'a core::num::wrapping::Wrapping<i32>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<i64>> for &'a core::num::wrapping::Wrapping<i64>
impl<'a> Sub<Wrapping<i64>> for &'a core::num::wrapping::Wrapping<i64>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<i128>> for &'a core::num::wrapping::Wrapping<i128>
impl<'a> Sub<Wrapping<i128>> for &'a core::num::wrapping::Wrapping<i128>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<isize>> for &'a core::num::wrapping::Wrapping<isize>
impl<'a> Sub<Wrapping<isize>> for &'a core::num::wrapping::Wrapping<isize>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<u8>> for &'a core::num::wrapping::Wrapping<u8>
impl<'a> Sub<Wrapping<u8>> for &'a core::num::wrapping::Wrapping<u8>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<u16>> for &'a core::num::wrapping::Wrapping<u16>
impl<'a> Sub<Wrapping<u16>> for &'a core::num::wrapping::Wrapping<u16>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<u32>> for &'a core::num::wrapping::Wrapping<u32>
impl<'a> Sub<Wrapping<u32>> for &'a core::num::wrapping::Wrapping<u32>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<u64>> for &'a core::num::wrapping::Wrapping<u64>
impl<'a> Sub<Wrapping<u64>> for &'a core::num::wrapping::Wrapping<u64>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<u128>> for &'a core::num::wrapping::Wrapping<u128>
impl<'a> Sub<Wrapping<u128>> for &'a core::num::wrapping::Wrapping<u128>
1.14.0 (const: unstable) · sourceimpl<'a> Sub<Wrapping<usize>> for &'a core::num::wrapping::Wrapping<usize>
impl<'a> Sub<Wrapping<usize>> for &'a core::num::wrapping::Wrapping<usize>
sourceimpl<'lhs, 'rhs, T, const LANES: usize> Sub<&'rhs Simd<T, LANES>> for &'lhs Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: Sub<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as Sub<Simd<T, LANES>>>::Output == Simd<T, LANES>,
impl<'lhs, 'rhs, T, const LANES: usize> Sub<&'rhs Simd<T, LANES>> for &'lhs Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: Sub<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as Sub<Simd<T, LANES>>>::Output == Simd<T, LANES>,
sourceimpl<C> Sub<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> Sub<&ScalarCore<C>> for ScalarCore<C> where
C: Curve,
type Output = ScalarCore<C>
sourceimpl<C> Sub<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
impl<C> Sub<ScalarCore<C>> for ScalarCore<C> where
C: Curve,
type Output = ScalarCore<C>
sourceimpl<T, A> Sub<&BTreeSet<T, A>> for &BTreeSet<T, A> where
T: Ord + Clone,
A: Allocator + Clone,
impl<T, A> Sub<&BTreeSet<T, A>> for &BTreeSet<T, A> where
T: Ord + Clone,
A: Allocator + Clone,
sourceimpl<T, S> Sub<&HashSet<T, S>> for &HashSet<T, S> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
impl<T, S> Sub<&HashSet<T, S>> for &HashSet<T, S> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
sourceimpl<T, const LANES: usize> Sub<&Simd<T, LANES>> for Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: Sub<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as Sub<Simd<T, LANES>>>::Output == Simd<T, LANES>,
impl<T, const LANES: usize> Sub<&Simd<T, LANES>> for Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: Sub<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as Sub<Simd<T, LANES>>>::Output == Simd<T, LANES>,
sourceimpl<T, const LANES: usize> Sub<Simd<T, LANES>> for &Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: Sub<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as Sub<Simd<T, LANES>>>::Output == Simd<T, LANES>,
impl<T, const LANES: usize> Sub<Simd<T, LANES>> for &Simd<T, LANES> where
T: SimdElement,
Simd<T, LANES>: Sub<Simd<T, LANES>>,
LaneCount<LANES>: SupportedLaneCount,
<Simd<T, LANES> as Sub<Simd<T, LANES>>>::Output == Simd<T, LANES>,
sourceimpl<U> Sub<B1> for UInt<U, B0> where
U: Unsigned + Sub<B1>,
<U as Sub<B1>>::Output: Unsigned,
impl<U> Sub<B1> for UInt<U, B0> where
U: Unsigned + Sub<B1>,
<U as Sub<B1>>::Output: Unsigned,
UInt<U, B0> - B1 = UInt<U - B1, B1>
sourceimpl<U, B> Sub<B1> for UInt<UInt<U, B>, B1> where
U: Unsigned,
B: Bit,
impl<U, B> Sub<B1> for UInt<UInt<U, B>, B1> where
U: Unsigned,
B: Bit,
UInt<U, B1> - B1 = UInt<U, B0>
sourceimpl<Ul, Bl, Ur> Sub<Ur> for UInt<Ul, Bl> where
Ul: Unsigned,
Bl: Bit,
Ur: Unsigned,
UInt<Ul, Bl>: PrivateSub<Ur>,
<UInt<Ul, Bl> as PrivateSub<Ur>>::Output: Trim,
impl<Ul, Bl, Ur> Sub<Ur> for UInt<Ul, Bl> where
Ul: Unsigned,
Bl: Bit,
Ur: Unsigned,
UInt<Ul, Bl>: PrivateSub<Ur>,
<UInt<Ul, Bl> as PrivateSub<Ur>>::Output: Trim,
Subtracting unsigned integers. We just do our PrivateSub
and then Trim
the output.
sourceimpl<Ul, Ur> Sub<NInt<Ur>> for NInt<Ul> where
Ul: Unsigned + NonZero,
Ur: Unsigned + NonZero + Cmp<Ul> + PrivateIntegerAdd<<Ur as Cmp<Ul>>::Output, Ul>,
impl<Ul, Ur> Sub<NInt<Ur>> for NInt<Ul> where
Ul: Unsigned + NonZero,
Ur: Unsigned + NonZero + Cmp<Ul> + PrivateIntegerAdd<<Ur as Cmp<Ul>>::Output, Ul>,
N(Ul) - N(Ur)
: We resolve this with our PrivateAdd
sourceimpl<Ul, Ur> Sub<NInt<Ur>> for PInt<Ul> where
Ul: Unsigned + NonZero + Add<Ur>,
Ur: Unsigned + NonZero,
<Ul as Add<Ur>>::Output: Unsigned,
<Ul as Add<Ur>>::Output: NonZero,
impl<Ul, Ur> Sub<NInt<Ur>> for PInt<Ul> where
Ul: Unsigned + NonZero + Add<Ur>,
Ur: Unsigned + NonZero,
<Ul as Add<Ur>>::Output: Unsigned,
<Ul as Add<Ur>>::Output: NonZero,
P(Ul) - N(Ur) = P(Ul + Ur)
sourceimpl<Ul, Ur> Sub<PInt<Ur>> for NInt<Ul> where
Ul: Unsigned + NonZero + Add<Ur>,
Ur: Unsigned + NonZero,
<Ul as Add<Ur>>::Output: Unsigned,
<Ul as Add<Ur>>::Output: NonZero,
impl<Ul, Ur> Sub<PInt<Ur>> for NInt<Ul> where
Ul: Unsigned + NonZero + Add<Ur>,
Ur: Unsigned + NonZero,
<Ul as Add<Ur>>::Output: Unsigned,
<Ul as Add<Ur>>::Output: NonZero,
N(Ul) - P(Ur) = N(Ul + Ur)
sourceimpl<Ul, Ur> Sub<PInt<Ur>> for PInt<Ul> where
Ul: Unsigned + NonZero + Cmp<Ur> + PrivateIntegerAdd<<Ul as Cmp<Ur>>::Output, Ur>,
Ur: Unsigned + NonZero,
impl<Ul, Ur> Sub<PInt<Ur>> for PInt<Ul> where
Ul: Unsigned + NonZero + Cmp<Ur> + PrivateIntegerAdd<<Ul as Cmp<Ur>>::Output, Ur>,
Ur: Unsigned + NonZero,
P(Ul) - P(Ur)
: We resolve this with our PrivateAdd