pub(crate) type SpanNanoseconds = ri64<{ _ }, { _ }>;
Expand description
A range of the allowed number of nanoseconds.
For this, we cannot cover the full span of supported time instants since
UnixSeconds::MAX * NANOSECONDS_PER_SECOND
cannot fit into 64-bits. We
could use a i128
, but it doesn’t seem worth it.
Also note that our min is equal to -max, so that the total number of values
in this range is one less than the number of distinct i64
values. We do
that so that the absolute value is always defined.
Aliased Type§
pub(crate) struct SpanNanoseconds {
pub(crate) val: i64,
pub(crate) min: i64,
pub(crate) max: i64,
}
Fields§
§val: i64
The actual value of the integer.
Callers should not access this directly. There are some very rare cases where algorithms are too difficult to express on ranged integers, and it’s useful to be able to reach inside and access the raw value directly. (For example, the conversions between Unix epoch day and Gregorian date.)
min: i64
The minimum possible value computed so far.
This value is only present when debug_assertions
are enabled.
In that case, it is used to ensure the minimum possible value
when the integer is actually observed (or converted) is still
within the legal range.
Callers should not access this directly. There are some very rare cases where algorithms are too difficult to express on ranged integers, and it’s useful to be able to reach inside and access the raw value directly. (For example, the conversions between Unix epoch day and Gregorian date.)
max: i64
The maximum possible value computed so far.
This value is only present when debug_assertions
are enabled.
In that case, it is used to ensure the maximum possible value
when the integer is actually observed (or converted) is still
within the legal range.
Callers should not access this directly. There are some very rare cases where algorithms are too difficult to express on ranged integers, and it’s useful to be able to reach inside and access the raw value directly. (For example, the conversions between Unix epoch day and Gregorian date.)