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<usize> for LibInBundleI
impl Sub<usize> for LibInBundleI
type Output = LibInBundleI
sourceimpl Sub<LibInBundleI> for usize
impl Sub<LibInBundleI> for usize
type Output = LibInBundleI
sourceimpl Sub<LibInBundleI> for LibInBundleI
impl Sub<LibInBundleI> for LibInBundleI
type Output = LibInBundleI
sourceimpl Sub<Duration> for NaiveDate
impl Sub<Duration> for NaiveDate
A subtraction of Duration
from NaiveDate
discards the fractional days,
rounding to the closest integral number of days towards Duration::zero()
.
It is the same as the addition with a negated Duration
.
Panics on underflow or overflow.
Use NaiveDate::checked_sub_signed
to detect that.
Example
use chrono::{Duration, NaiveDate};
let from_ymd = NaiveDate::from_ymd;
assert_eq!(from_ymd(2014, 1, 1) - Duration::zero(), from_ymd(2014, 1, 1));
assert_eq!(from_ymd(2014, 1, 1) - Duration::seconds(86399), from_ymd(2014, 1, 1));
assert_eq!(from_ymd(2014, 1, 1) - Duration::seconds(-86399), from_ymd(2014, 1, 1));
assert_eq!(from_ymd(2014, 1, 1) - Duration::days(1), from_ymd(2013, 12, 31));
assert_eq!(from_ymd(2014, 1, 1) - Duration::days(-1), from_ymd(2014, 1, 2));
assert_eq!(from_ymd(2014, 1, 1) - Duration::days(364), from_ymd(2013, 1, 2));
assert_eq!(from_ymd(2014, 1, 1) - Duration::days(365*4 + 1), from_ymd(2010, 1, 1));
assert_eq!(from_ymd(2014, 1, 1) - Duration::days(365*400 + 97), from_ymd(1614, 1, 1));
sourceimpl Sub<Duration> for NaiveDateTime
impl Sub<Duration> for NaiveDateTime
A subtraction of Duration
from NaiveDateTime
yields another NaiveDateTime
.
It is the same as the addition with a negated Duration
.
As a part of Chrono’s leap second handling,
the addition assumes that there is no leap second ever,
except when the NaiveDateTime
itself represents a leap second
in which case the assumption becomes that there is exactly a single leap second ever.
Panics on underflow or overflow.
Use NaiveDateTime::checked_sub_signed
to detect that.
Example
use chrono::{Duration, NaiveDate};
let from_ymd = NaiveDate::from_ymd;
let d = from_ymd(2016, 7, 8);
let hms = |h, m, s| d.and_hms(h, m, s);
assert_eq!(hms(3, 5, 7) - Duration::zero(), hms(3, 5, 7));
assert_eq!(hms(3, 5, 7) - Duration::seconds(1), hms(3, 5, 6));
assert_eq!(hms(3, 5, 7) - Duration::seconds(-1), hms(3, 5, 8));
assert_eq!(hms(3, 5, 7) - Duration::seconds(3600 + 60), hms(2, 4, 7));
assert_eq!(hms(3, 5, 7) - Duration::seconds(86_400),
from_ymd(2016, 7, 7).and_hms(3, 5, 7));
assert_eq!(hms(3, 5, 7) - Duration::days(365),
from_ymd(2015, 7, 9).and_hms(3, 5, 7));
let hmsm = |h, m, s, milli| d.and_hms_milli(h, m, s, milli);
assert_eq!(hmsm(3, 5, 7, 450) - Duration::milliseconds(670), hmsm(3, 5, 6, 780));
Leap seconds are handled, but the subtraction assumes that it is the only leap second happened.
let leap = hmsm(3, 5, 59, 1_300);
assert_eq!(leap - Duration::zero(), hmsm(3, 5, 59, 1_300));
assert_eq!(leap - Duration::milliseconds(200), hmsm(3, 5, 59, 1_100));
assert_eq!(leap - Duration::milliseconds(500), hmsm(3, 5, 59, 800));
assert_eq!(leap - Duration::seconds(60), hmsm(3, 5, 0, 300));
assert_eq!(leap - Duration::days(1),
from_ymd(2016, 7, 7).and_hms_milli(3, 6, 0, 300));
type Output = NaiveDateTime
sourceimpl Sub<Duration> for NaiveTime
impl Sub<Duration> for NaiveTime
A subtraction of Duration
from NaiveTime
wraps around and never overflows or underflows.
In particular the addition ignores integral number of days.
It is the same as the addition with a negated Duration
.
As a part of Chrono’s leap second handling,
the addition assumes that there is no leap second ever,
except when the NaiveTime
itself represents a leap second
in which case the assumption becomes that there is exactly a single leap second ever.
Example
use chrono::{Duration, NaiveTime};
let from_hmsm = NaiveTime::from_hms_milli;
assert_eq!(from_hmsm(3, 5, 7, 0) - Duration::zero(), from_hmsm(3, 5, 7, 0));
assert_eq!(from_hmsm(3, 5, 7, 0) - Duration::seconds(1), from_hmsm(3, 5, 6, 0));
assert_eq!(from_hmsm(3, 5, 7, 0) - Duration::seconds(60 + 5), from_hmsm(3, 4, 2, 0));
assert_eq!(from_hmsm(3, 5, 7, 0) - Duration::seconds(2*60*60 + 6*60), from_hmsm(0, 59, 7, 0));
assert_eq!(from_hmsm(3, 5, 7, 0) - Duration::milliseconds(80), from_hmsm(3, 5, 6, 920));
assert_eq!(from_hmsm(3, 5, 7, 950) - Duration::milliseconds(280), from_hmsm(3, 5, 7, 670));
The subtraction wraps around.
assert_eq!(from_hmsm(3, 5, 7, 0) - Duration::seconds(8*60*60), from_hmsm(19, 5, 7, 0));
assert_eq!(from_hmsm(3, 5, 7, 0) - Duration::days(800), from_hmsm(3, 5, 7, 0));
Leap seconds are handled, but the subtraction assumes that it is the only leap second happened.
let leap = from_hmsm(3, 5, 59, 1_300);
assert_eq!(leap - Duration::zero(), from_hmsm(3, 5, 59, 1_300));
assert_eq!(leap - Duration::milliseconds(200), from_hmsm(3, 5, 59, 1_100));
assert_eq!(leap - Duration::milliseconds(500), from_hmsm(3, 5, 59, 800));
assert_eq!(leap - Duration::seconds(60), from_hmsm(3, 5, 0, 300));
assert_eq!(leap - Duration::days(1), from_hmsm(3, 6, 0, 300));
sourceimpl Sub<Duration> for SteadyTime
impl Sub<Duration> for SteadyTime
type Output = SteadyTime
sourceimpl Sub<FixedOffset> for NaiveDateTime
impl Sub<FixedOffset> for NaiveDateTime
type Output = NaiveDateTime
sourceimpl Sub<NaiveDate> for NaiveDate
impl Sub<NaiveDate> for NaiveDate
Subtracts another NaiveDate
from the current date.
Returns a Duration
of integral numbers.
This does not overflow or underflow at all,
as all possible output fits in the range of Duration
.
The implementation is a wrapper around
NaiveDate::signed_duration_since
.
Example
use chrono::{Duration, NaiveDate};
let from_ymd = NaiveDate::from_ymd;
assert_eq!(from_ymd(2014, 1, 1) - from_ymd(2014, 1, 1), Duration::zero());
assert_eq!(from_ymd(2014, 1, 1) - from_ymd(2013, 12, 31), Duration::days(1));
assert_eq!(from_ymd(2014, 1, 1) - from_ymd(2014, 1, 2), Duration::days(-1));
assert_eq!(from_ymd(2014, 1, 1) - from_ymd(2013, 9, 23), Duration::days(100));
assert_eq!(from_ymd(2014, 1, 1) - from_ymd(2013, 1, 1), Duration::days(365));
assert_eq!(from_ymd(2014, 1, 1) - from_ymd(2010, 1, 1), Duration::days(365*4 + 1));
assert_eq!(from_ymd(2014, 1, 1) - from_ymd(1614, 1, 1), Duration::days(365*400 + 97));
sourceimpl Sub<NaiveDateTime> for NaiveDateTime
impl Sub<NaiveDateTime> for NaiveDateTime
Subtracts another NaiveDateTime
from the current date and time.
This does not overflow or underflow at all.
As a part of Chrono’s leap second handling,
the subtraction assumes that there is no leap second ever,
except when any of the NaiveDateTime
s themselves represents a leap second
in which case the assumption becomes that
there are exactly one (or two) leap second(s) ever.
The implementation is a wrapper around
NaiveDateTime::signed_duration_since
.
Example
use chrono::{Duration, NaiveDate};
let from_ymd = NaiveDate::from_ymd;
let d = from_ymd(2016, 7, 8);
assert_eq!(d.and_hms(3, 5, 7) - d.and_hms(2, 4, 6), Duration::seconds(3600 + 60 + 1));
// July 8 is 190th day in the year 2016
let d0 = from_ymd(2016, 1, 1);
assert_eq!(d.and_hms_milli(0, 7, 6, 500) - d0.and_hms(0, 0, 0),
Duration::seconds(189 * 86_400 + 7 * 60 + 6) + Duration::milliseconds(500));
Leap seconds are handled, but the subtraction assumes that there were no other leap seconds happened.
let leap = from_ymd(2015, 6, 30).and_hms_milli(23, 59, 59, 1_500);
assert_eq!(leap - from_ymd(2015, 6, 30).and_hms(23, 0, 0),
Duration::seconds(3600) + Duration::milliseconds(500));
assert_eq!(from_ymd(2015, 7, 1).and_hms(1, 0, 0) - leap,
Duration::seconds(3600) - Duration::milliseconds(500));
sourceimpl Sub<NaiveTime> for NaiveTime
impl Sub<NaiveTime> for NaiveTime
Subtracts another NaiveTime
from the current time.
Returns a Duration
within +/- 1 day.
This does not overflow or underflow at all.
As a part of Chrono’s leap second handling,
the subtraction assumes that there is no leap second ever,
except when any of the NaiveTime
s themselves represents a leap second
in which case the assumption becomes that
there are exactly one (or two) leap second(s) ever.
The implementation is a wrapper around
NaiveTime::signed_duration_since
.
Example
use chrono::{Duration, NaiveTime};
let from_hmsm = NaiveTime::from_hms_milli;
assert_eq!(from_hmsm(3, 5, 7, 900) - from_hmsm(3, 5, 7, 900), Duration::zero());
assert_eq!(from_hmsm(3, 5, 7, 900) - from_hmsm(3, 5, 7, 875), Duration::milliseconds(25));
assert_eq!(from_hmsm(3, 5, 7, 900) - from_hmsm(3, 5, 6, 925), Duration::milliseconds(975));
assert_eq!(from_hmsm(3, 5, 7, 900) - from_hmsm(3, 5, 0, 900), Duration::seconds(7));
assert_eq!(from_hmsm(3, 5, 7, 900) - from_hmsm(3, 0, 7, 900), Duration::seconds(5 * 60));
assert_eq!(from_hmsm(3, 5, 7, 900) - from_hmsm(0, 5, 7, 900), Duration::seconds(3 * 3600));
assert_eq!(from_hmsm(3, 5, 7, 900) - from_hmsm(4, 5, 7, 900), Duration::seconds(-3600));
assert_eq!(from_hmsm(3, 5, 7, 900) - from_hmsm(2, 4, 6, 800),
Duration::seconds(3600 + 60 + 1) + Duration::milliseconds(100));
Leap seconds are handled, but the subtraction assumes that there were no other leap seconds happened.
assert_eq!(from_hmsm(3, 0, 59, 1_000) - from_hmsm(3, 0, 59, 0), Duration::seconds(1));
assert_eq!(from_hmsm(3, 0, 59, 1_500) - from_hmsm(3, 0, 59, 0),
Duration::milliseconds(1500));
assert_eq!(from_hmsm(3, 0, 59, 1_000) - from_hmsm(3, 0, 0, 0), Duration::seconds(60));
assert_eq!(from_hmsm(3, 0, 0, 0) - from_hmsm(2, 59, 59, 1_000), Duration::seconds(1));
assert_eq!(from_hmsm(3, 0, 59, 1_000) - from_hmsm(2, 59, 59, 1_000),
Duration::seconds(61));
impl Sub<FallocateFlags> for FallocateFlags
impl Sub<FallocateFlags> for FallocateFlags
type Output = FallocateFlags
impl Sub<RenameFlags> for RenameFlags
impl Sub<RenameFlags> for RenameFlags
type Output = RenameFlags
impl Sub<SpliceFFlags> for SpliceFFlags
impl Sub<SpliceFFlags> for SpliceFFlags
type Output = SpliceFFlags
impl Sub<DeleteModuleFlags> for DeleteModuleFlags
impl Sub<DeleteModuleFlags> for DeleteModuleFlags
type Output = DeleteModuleFlags
impl Sub<ModuleInitFlags> for ModuleInitFlags
impl Sub<ModuleInitFlags> for ModuleInitFlags
type Output = ModuleInitFlags
impl Sub<InterfaceFlags> for InterfaceFlags
impl Sub<InterfaceFlags> for InterfaceFlags
type Output = InterfaceFlags
impl Sub<CloneFlags> for CloneFlags
impl Sub<CloneFlags> for CloneFlags
type Output = CloneFlags
impl Sub<EpollCreateFlags> for EpollCreateFlags
impl Sub<EpollCreateFlags> for EpollCreateFlags
type Output = EpollCreateFlags
impl Sub<EpollFlags> for EpollFlags
impl Sub<EpollFlags> for EpollFlags
type Output = EpollFlags
impl Sub<AddWatchFlags> for AddWatchFlags
impl Sub<AddWatchFlags> for AddWatchFlags
type Output = AddWatchFlags
impl Sub<MemFdCreateFlag> for MemFdCreateFlag
impl Sub<MemFdCreateFlag> for MemFdCreateFlag
type Output = MemFdCreateFlag
impl Sub<MRemapFlags> for MRemapFlags
impl Sub<MRemapFlags> for MRemapFlags
type Output = MRemapFlags
impl Sub<MlockAllFlags> for MlockAllFlags
impl Sub<MlockAllFlags> for MlockAllFlags
type Output = MlockAllFlags
impl Sub<QuotaValidFlags> for QuotaValidFlags
impl Sub<QuotaValidFlags> for QuotaValidFlags
type Output = QuotaValidFlags
impl Sub<TimestampingFlag> for TimestampingFlag
impl Sub<TimestampingFlag> for TimestampingFlag
type Output = TimestampingFlag
impl Sub<ControlFlags> for ControlFlags
impl Sub<ControlFlags> for ControlFlags
type Output = ControlFlags
impl Sub<InputFlags> for InputFlags
impl Sub<InputFlags> for InputFlags
type Output = InputFlags
impl Sub<LocalFlags> for LocalFlags
impl Sub<LocalFlags> for LocalFlags
type Output = LocalFlags
impl Sub<OutputFlags> for OutputFlags
impl Sub<OutputFlags> for OutputFlags
type Output = OutputFlags
impl Sub<TimerSetTimeFlags> for TimerSetTimeFlags
impl Sub<TimerSetTimeFlags> for TimerSetTimeFlags
type Output = TimerSetTimeFlags
impl Sub<TimerFlags> for TimerFlags
impl Sub<TimerFlags> for TimerFlags
type Output = TimerFlags
impl Sub<WaitPidFlag> for WaitPidFlag
impl Sub<WaitPidFlag> for WaitPidFlag
type Output = WaitPidFlag
impl Sub<AccessFlags> for AccessFlags
impl Sub<AccessFlags> for AccessFlags
type Output = AccessFlags
impl Sub<SystemTime> for OffsetDateTime
impl Sub<SystemTime> for OffsetDateTime
type Output = Duration
1.8.0 · sourceimpl Sub<Duration> for SystemTime
impl Sub<Duration> for SystemTime
type Output = SystemTime
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>
sourceimpl Sub<SteadyTime> for SteadyTime
impl Sub<SteadyTime> for SteadyTime
sourceimpl Sub<CMSOptions> for CMSOptions
impl Sub<CMSOptions> for CMSOptions
type Output = CMSOptions
sourceimpl Sub<Pkcs7Flags> for Pkcs7Flags
impl Sub<Pkcs7Flags> for Pkcs7Flags
type Output = Pkcs7Flags
sourceimpl Sub<ExtensionContext> for ExtensionContext
impl Sub<ExtensionContext> for ExtensionContext
type Output = ExtensionContext
sourceimpl Sub<ShutdownState> for ShutdownState
impl Sub<ShutdownState> for ShutdownState
type Output = ShutdownState
sourceimpl Sub<SslOptions> for SslOptions
impl Sub<SslOptions> for SslOptions
type Output = SslOptions
sourceimpl Sub<SslSessionCacheMode> for SslSessionCacheMode
impl Sub<SslSessionCacheMode> for SslSessionCacheMode
type Output = SslSessionCacheMode
sourceimpl Sub<SslVerifyMode> for SslVerifyMode
impl Sub<SslVerifyMode> for SslVerifyMode
type Output = SslVerifyMode
sourceimpl Sub<X509CheckFlags> for X509CheckFlags
impl Sub<X509CheckFlags> for X509CheckFlags
type Output = X509CheckFlags
sourceimpl Sub<X509VerifyFlags> for X509VerifyFlags
impl Sub<X509VerifyFlags> for X509VerifyFlags
type Output = X509VerifyFlags
impl Sub<Duration> for SystemTime
impl Sub<Duration> for SystemTime
type Output = SystemTime
impl Sub<OffsetDateTime> for SystemTime
impl Sub<OffsetDateTime> for SystemTime
type Output = Duration
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<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<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<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<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<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<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<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<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<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<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<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<'_, '_, 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, S1, S2> Sub<&IndexSet<T, S2>> for &IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
impl<'_, '_, T, S1, S2> Sub<&IndexSet<T, S2>> for &IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
sourceimpl<'_, '_, T, S> Sub<&HashSet<T, S>> for &otter_nodejs_tests::HashSet<T, S> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
impl<'_, '_, T, S> Sub<&HashSet<T, S>> for &otter_nodejs_tests::HashSet<T, S> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
impl<'_, '_, T, S> Sub<&HashSet<T, S, Global>> for &HashSet<T, S, Global> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
impl<'_, '_, T, S> Sub<&HashSet<T, S, Global>> for &HashSet<T, S, Global> where
T: Eq + Hash + Clone,
S: BuildHasher + Default,
type Output = HashSet<T, S, Global>
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<'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
impl<'a, T> Sub<&'a OrderedFloat<T>> for OrderedFloat<T> where
T: Sub<&'a T>,
impl<'a, T> Sub<&'a OrderedFloat<T>> for OrderedFloat<T> where
T: Sub<&'a T>,
type Output = OrderedFloat<<T as Sub<&'a T>>::Output>
impl<'a, T> Sub<&'a T> for OrderedFloat<T> where
T: Sub<&'a T>,
impl<'a, T> Sub<&'a T> for OrderedFloat<T> where
T: Sub<&'a T>,
type Output = OrderedFloat<<T as Sub<&'a T>>::Output>
impl<'a, T> Sub<OrderedFloat<T>> for &'a OrderedFloat<T> where
&'a T: Sub<T>,
impl<'a, T> Sub<OrderedFloat<T>> for &'a OrderedFloat<T> where
&'a T: Sub<T>,
type Output = OrderedFloat<<&'a T as Sub<T>>::Output>
impl<'a, T> Sub<T> for &'a OrderedFloat<T> where
&'a T: Sub<T>,
impl<'a, T> Sub<T> for &'a OrderedFloat<T> where
&'a T: Sub<T>,
type Output = OrderedFloat<<&'a T as Sub<T>>::Output>
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>,
impl<T> Sub<OrderedFloat<T>> for OrderedFloat<T> where
T: Sub<T>,
impl<T> Sub<OrderedFloat<T>> for OrderedFloat<T> where
T: Sub<T>,
type Output = OrderedFloat<<T as Sub<T>>::Output>
impl<T> Sub<PosC<T>> for PosC<T> where
T: CheckedArith,
impl<T> Sub<PosC<T>> for PosC<T> where
T: CheckedArith,
type Output = Result<PosC<T>, CoordinateOverflow>
impl<T> Sub<T> for NotNan<T> where
T: Float,
impl<T> Sub<T> for NotNan<T> where
T: Float,
Subtracts a float directly.
Panics if the provided value is NaN or the computation results in NaN
impl<T> Sub<T> for OrderedFloat<T> where
T: Sub<T>,
impl<T> Sub<T> for OrderedFloat<T> where
T: Sub<T>,
type Output = OrderedFloat<<T as Sub<T>>::Output>
impl<T> Sub<T> for OffsetDateTime where
PrimitiveDateTime: Sub<T>,
<PrimitiveDateTime as Sub<T>>::Output == PrimitiveDateTime,
impl<T> Sub<T> for OffsetDateTime where
PrimitiveDateTime: Sub<T>,
<PrimitiveDateTime as Sub<T>>::Output == PrimitiveDateTime,
type Output = OffsetDateTime
sourceimpl<Tz> Sub<Date<Tz>> for otter_nodejs_tests::otter_support::crates::chrono::Date<Tz> where
Tz: TimeZone,
impl<Tz> Sub<Date<Tz>> for otter_nodejs_tests::otter_support::crates::chrono::Date<Tz> where
Tz: TimeZone,
sourceimpl<Tz> Sub<Duration> for otter_nodejs_tests::otter_support::crates::chrono::Date<Tz> where
Tz: TimeZone,
impl<Tz> Sub<Duration> for otter_nodejs_tests::otter_support::crates::chrono::Date<Tz> where
Tz: TimeZone,
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