pub(crate) type NoUnits = ri64<{ _ }, { _ }>;
Expand description
A type alias for a ranged integer with no units.
In particular, the range of this type is just the range of an i64
. This
is useful when too many things with different units need to be combined at
once, and it’s just too painful to keep them straight. In cases like that,
it’s useful to just convert everything to NoUnits
, do the necessary math,
and then convert back to the appropriate ranged types.
Note that we don’t actually lose much by doing this, since the computed min/max values are retained even when converting to and from this type. In general, this type is just about making some math easier by making everything uniform.
Aliased Type§
pub(crate) struct NoUnits {
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.)