type WholeSeconds = RangedI32<{ _ }, { _ }>;
Expand description
The type capable of storing the range of whole seconds that a UtcOffset
can encompass.
Aliased Type§
struct WholeSeconds(/* private fields */);
Implementations
Source§impl<const MIN: i32, const MAX: i32> RangedI32<MIN, MAX>
impl<const MIN: i32, const MAX: i32> RangedI32<MIN, MAX>
Sourcepub const unsafe fn new_unchecked(value: i32) -> RangedI32<MIN, MAX>
pub const unsafe fn new_unchecked(value: i32) -> RangedI32<MIN, MAX>
Creates a ranged integer without checking the value.
§Safety
The value must be within the range MIN..=MAX
.
Sourcepub const fn new(value: i32) -> Option<RangedI32<MIN, MAX>>
pub const fn new(value: i32) -> Option<RangedI32<MIN, MAX>>
Creates a ranged integer if the given value is in the range MIN..=MAX
.
Sourcepub const fn new_static<const VALUE: i32>() -> RangedI32<MIN, MAX>
pub const fn new_static<const VALUE: i32>() -> RangedI32<MIN, MAX>
Creates a ranged integer with a statically known value. Fails to compile if the value is not in range.
Sourcepub const fn new_saturating(value: i32) -> RangedI32<MIN, MAX>
pub const fn new_saturating(value: i32) -> RangedI32<MIN, MAX>
Creates a ranged integer with the given value, saturating if it is out of range.
Sourcepub const fn expand<const NEW_MIN: i32, const NEW_MAX: i32>(
self,
) -> RangedI32<NEW_MIN, NEW_MAX>
pub const fn expand<const NEW_MIN: i32, const NEW_MAX: i32>( self, ) -> RangedI32<NEW_MIN, NEW_MAX>
Expand the range that the value may be in. Fails to compile if the new range is not a superset of the current range.
Sourcepub const fn narrow<const NEW_MIN: i32, const NEW_MAX: i32>(
self,
) -> Option<RangedI32<NEW_MIN, NEW_MAX>>
pub const fn narrow<const NEW_MIN: i32, const NEW_MAX: i32>( self, ) -> Option<RangedI32<NEW_MIN, NEW_MAX>>
Attempt to narrow the range that the value may be in. Returns None
if the value
is outside the new range. Fails to compile if the new range is not a subset of
the current range.
Sourcepub fn from_str_radix(
src: &str,
radix: u32,
) -> Result<RangedI32<MIN, MAX>, ParseIntError>
pub fn from_str_radix( src: &str, radix: u32, ) -> Result<RangedI32<MIN, MAX>, ParseIntError>
Converts a string slice in a given base to an integer.
The string is expected to be an optional +
or -
sign followed by digits. Leading
and trailing whitespace represent an error. Digits are a subset of these characters,
depending on radix
:
0-9
a-z
A-Z
§Panics
Panics if radix
is not in the range 2..=36
.
§Examples
Basic usage:
Sourcepub const fn checked_add(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_add(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
Checked integer addition. Computes self + rhs
, returning None
if the resulting
value is out of range.
Sourcepub const unsafe fn unchecked_add(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_add(self, rhs: i32) -> RangedI32<MIN, MAX>
Unchecked integer addition. Computes self + rhs
, assuming that the result is in
range.
§Safety
The result of self + rhs
must be in the range MIN..=MAX
.
Sourcepub const fn checked_sub(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_sub(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
Checked integer addition. Computes self - rhs
, returning None
if the resulting
value is out of range.
Sourcepub const unsafe fn unchecked_sub(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_sub(self, rhs: i32) -> RangedI32<MIN, MAX>
Unchecked integer subtraction. Computes self - rhs
, assuming that the result is in
range.
§Safety
The result of self - rhs
must be in the range MIN..=MAX
.
Sourcepub const fn checked_mul(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_mul(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
Checked integer addition. Computes self * rhs
, returning None
if the resulting
value is out of range.
Sourcepub const unsafe fn unchecked_mul(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_mul(self, rhs: i32) -> RangedI32<MIN, MAX>
Unchecked integer multiplication. Computes self * rhs
, assuming that the result is
in range.
§Safety
The result of self * rhs
must be in the range MIN..=MAX
.
Sourcepub const fn checked_div(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_div(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
Checked integer addition. Computes self / rhs
, returning None
if rhs == 0
or
if the resulting value is out of range.
Sourcepub const unsafe fn unchecked_div(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_div(self, rhs: i32) -> RangedI32<MIN, MAX>
Unchecked integer division. Computes self / rhs
, assuming that rhs != 0
and that
the result is in range.
§Safety
self
must not be zero and the result of self / rhs
must be in the range
MIN..=MAX
.
Sourcepub const fn checked_div_euclid(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_div_euclid(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
Checked Euclidean division. Computes self.div_euclid(rhs)
, returning None
if
rhs == 0
or if the resulting value is out of range.
Sourcepub const unsafe fn unchecked_div_euclid(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_div_euclid(self, rhs: i32) -> RangedI32<MIN, MAX>
Unchecked Euclidean division. Computes self.div_euclid(rhs)
, assuming that
rhs != 0
and that the result is in range.
§Safety
self
must not be zero and the result of self.div_euclid(rhs)
must be in the
range MIN..=MAX
.
Sourcepub const fn checked_rem(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_rem(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
Checked integer remainder. Computes self % rhs
, returning None
if rhs == 0
or
if the resulting value is out of range.
Sourcepub const unsafe fn unchecked_rem(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_rem(self, rhs: i32) -> RangedI32<MIN, MAX>
Unchecked remainder. Computes self % rhs
, assuming that rhs != 0
and that the
result is in range.
§Safety
self
must not be zero and the result of self % rhs
must be in the range
MIN..=MAX
.
Sourcepub const fn checked_rem_euclid(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_rem_euclid(self, rhs: i32) -> Option<RangedI32<MIN, MAX>>
Checked Euclidean remainder. Computes self.rem_euclid(rhs)
, returning None
if
rhs == 0
or if the resulting value is out of range.
Sourcepub const unsafe fn unchecked_rem_euclid(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_rem_euclid(self, rhs: i32) -> RangedI32<MIN, MAX>
Unchecked Euclidean remainder. Computes self.rem_euclid(rhs)
, assuming that
rhs != 0
and that the result is in range.
§Safety
self
must not be zero and the result of self.rem_euclid(rhs)
must be in the
range MIN..=MAX
.
Sourcepub const fn checked_neg(self) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_neg(self) -> Option<RangedI32<MIN, MAX>>
Checked negation. Computes -self
, returning None
if the resulting value is out
of range.
Sourcepub const unsafe fn unchecked_neg(self) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_neg(self) -> RangedI32<MIN, MAX>
Unchecked negation. Computes -self
, assuming that -self
is in range.
§Safety
The result of -self
must be in the range MIN..=MAX
.
Sourcepub const fn neg(self) -> RangedI32<MIN, MAX>
pub const fn neg(self) -> RangedI32<MIN, MAX>
Negation. Computes self.neg()
, failing to compile if the result is not
guaranteed to be in range.
Sourcepub const fn checked_shl(self, rhs: u32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_shl(self, rhs: u32) -> Option<RangedI32<MIN, MAX>>
Checked shift left. Computes self << rhs
, returning None
if the resulting value
is out of range.
Sourcepub const unsafe fn unchecked_shl(self, rhs: u32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_shl(self, rhs: u32) -> RangedI32<MIN, MAX>
Unchecked shift left. Computes self << rhs
, assuming that the result is in range.
§Safety
The result of self << rhs
must be in the range MIN..=MAX
.
Sourcepub const fn checked_shr(self, rhs: u32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_shr(self, rhs: u32) -> Option<RangedI32<MIN, MAX>>
Checked shift right. Computes self >> rhs
, returning None
if
the resulting value is out of range.
Sourcepub const unsafe fn unchecked_shr(self, rhs: u32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_shr(self, rhs: u32) -> RangedI32<MIN, MAX>
Unchecked shift right. Computes self >> rhs
, assuming that the result is in range.
§Safety
The result of self >> rhs
must be in the range MIN..=MAX
.
Sourcepub const fn checked_abs(self) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_abs(self) -> Option<RangedI32<MIN, MAX>>
Checked absolute value. Computes self.abs()
, returning None
if the resulting
value is out of range.
Sourcepub const unsafe fn unchecked_abs(self) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_abs(self) -> RangedI32<MIN, MAX>
Unchecked absolute value. Computes self.abs()
, assuming that the result is in
range.
§Safety
The result of self.abs()
must be in the range MIN..=MAX
.
Sourcepub const fn abs(self) -> RangedI32<MIN, MAX>
pub const fn abs(self) -> RangedI32<MIN, MAX>
Absolute value. Computes self.abs()
, failing to compile if the result is not
guaranteed to be in range.
Sourcepub const fn checked_pow(self, exp: u32) -> Option<RangedI32<MIN, MAX>>
pub const fn checked_pow(self, exp: u32) -> Option<RangedI32<MIN, MAX>>
Checked exponentiation. Computes self.pow(exp)
, returning None
if the resulting
value is out of range.
Sourcepub const unsafe fn unchecked_pow(self, exp: u32) -> RangedI32<MIN, MAX>
pub const unsafe fn unchecked_pow(self, exp: u32) -> RangedI32<MIN, MAX>
Unchecked exponentiation. Computes self.pow(exp)
, assuming that the result is in
range.
§Safety
The result of self.pow(exp)
must be in the range MIN..=MAX
.
Sourcepub const fn saturating_add(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const fn saturating_add(self, rhs: i32) -> RangedI32<MIN, MAX>
Saturating integer addition. Computes self + rhs
, saturating at the numeric
bounds.
Sourcepub const fn saturating_sub(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const fn saturating_sub(self, rhs: i32) -> RangedI32<MIN, MAX>
Saturating integer subtraction. Computes self - rhs
, saturating at the numeric
bounds.
Sourcepub const fn saturating_neg(self) -> RangedI32<MIN, MAX>
pub const fn saturating_neg(self) -> RangedI32<MIN, MAX>
Saturating integer negation. Computes self - rhs
, saturating at the numeric
bounds.
Sourcepub const fn saturating_abs(self) -> RangedI32<MIN, MAX>
pub const fn saturating_abs(self) -> RangedI32<MIN, MAX>
Saturating absolute value. Computes self.abs()
, saturating at the numeric bounds.
Sourcepub const fn saturating_mul(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const fn saturating_mul(self, rhs: i32) -> RangedI32<MIN, MAX>
Saturating integer multiplication. Computes self * rhs
, saturating at the numeric
bounds.
Sourcepub const fn saturating_pow(self, exp: u32) -> RangedI32<MIN, MAX>
pub const fn saturating_pow(self, exp: u32) -> RangedI32<MIN, MAX>
Saturating integer exponentiation. Computes self.pow(exp)
, saturating at the
numeric bounds.
Sourcepub const fn wrapping_add(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const fn wrapping_add(self, rhs: i32) -> RangedI32<MIN, MAX>
Wrapping integer addition. Computes self + rhs
, wrapping around the numeric
bounds.
Sourcepub const fn wrapping_sub(self, rhs: i32) -> RangedI32<MIN, MAX>
pub const fn wrapping_sub(self, rhs: i32) -> RangedI32<MIN, MAX>
Wrapping integer subtraction. Computes self - rhs
, wrapping around the numeric
bounds.
Trait Implementations
Source§impl<const MIN: i32, const MAX: i32> Arbitrary for RangedI32<MIN, MAX>
Available on crate feature quickcheck
only.
impl<const MIN: i32, const MAX: i32> Arbitrary for RangedI32<MIN, MAX>
quickcheck
only.Source§impl<'de, const MIN: i32, const MAX: i32> Deserialize<'de> for RangedI32<MIN, MAX>
Available on crate feature serde
only.
impl<'de, const MIN: i32, const MAX: i32> Deserialize<'de> for RangedI32<MIN, MAX>
serde
only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<RangedI32<MIN, MAX>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<RangedI32<MIN, MAX>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§#[doc(hidden)] fn deserialize_in_place<D>(
deserializer: D,
place: &mut Self,
) -> Result<(), <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
#[doc(hidden)] fn deserialize_in_place<D>(
deserializer: D,
place: &mut Self,
) -> Result<(), <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
self
from the given Deserializer. Read moreSource§impl<const MIN: i32, const MAX: i32> Eq for RangedI32<MIN, MAX>
impl<const MIN: i32, const MAX: i32> Eq for RangedI32<MIN, MAX>
#[doc(hidden)] fn assert_receiver_is_total_eq(&self)
Source§impl<const MIN: i32, const MAX: i32> Ord for RangedI32<MIN, MAX>
impl<const MIN: i32, const MAX: i32> Ord for RangedI32<MIN, MAX>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<const MIN_A: i32, const MAX_A: i32, const MIN_B: i32, const MAX_B: i32> PartialEq<RangedI32<MIN_B, MAX_B>> for RangedI32<MIN_A, MAX_A>
impl<const MIN_A: i32, const MAX_A: i32, const MIN_B: i32, const MAX_B: i32> PartialEq<RangedI32<MIN_B, MAX_B>> for RangedI32<MIN_A, MAX_A>
Source§impl<const MIN_A: i32, const MAX_A: i32, const MIN_B: i32, const MAX_B: i32> PartialOrd<RangedI32<MIN_B, MAX_B>> for RangedI32<MIN_A, MAX_A>
impl<const MIN_A: i32, const MAX_A: i32, const MIN_B: i32, const MAX_B: i32> PartialOrd<RangedI32<MIN_B, MAX_B>> for RangedI32<MIN_A, MAX_A>
Source§impl<const MIN: i32, const MAX: i32> Serialize for RangedI32<MIN, MAX>
Available on crate feature serde
only.
impl<const MIN: i32, const MAX: i32> Serialize for RangedI32<MIN, MAX>
serde
only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl<const MIN: i32, const MAX: i32> SmartDisplay for RangedI32<MIN, MAX>
Available on crate feature powerfmt
only.
impl<const MIN: i32, const MAX: i32> SmartDisplay for RangedI32<MIN, MAX>
powerfmt
only.