Struct constrained_int::i32::ConstrainedI32
source · [−]#[repr(transparent)]pub struct ConstrainedI32<const MIN: i32, const MAX: i32, const DEF: i32 = MIN>(_);
Expand description
An i32
value that is constrained within an inclusive range.
The range is defined at compile time, by assigning values to the parameters
MIN
and MAX
. MIN
indicates the lower inclusive bound of the range,
while MAX
indicateds the upper inclusive bound. The value will always
be contained within the defined range once it’s constructed.
The condition MAX
> MIN
must be satified, or else the type can’t
be constructed.
A default can be supplied by assigning a value to the parameter DEF
. The
default value must be contained by the range, meaning: MIN
<= DEF
<= MAX
.
Or else the type can’t be constructed.
It’s also required that either MIN
to be greater than the primitive’s MIN
or MAX
to be lower than the primitive’s MAX
, or else the type can’t be
constructed.
Examples
If the provided parameters satisfy the construction condition, associated constants and type constructors are acessible.
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
assert_eq!(Constrained::MIN, -127);
assert_eq!(Constrained::MAX, 126);
assert_eq!(Constrained::DEF, -127);
let constrained = Constrained::new(-127)?;
assert_eq!(constrained.get(), -127);
Associated constants and type constructors are guarded against parameters
that violate the MAX
> MIN
condition.
use constrained_int::i32::ConstrainedI32;
// MIN greater or equal to MAX does not satisfy the construction condition.
type InvalidRange = ConstrainedI32<126, -127>;
// None of these will compile for InvalidRange.
let value = InvalidRange::MIN;
let constrained = InvalidRange::default();
let constrained = InvalidRange::min();
/* ...other constructors */
Implementations
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> ConstrainedI32<MIN, MAX, DEF> where
Guard<{ _ }>: Protect,
impl<const MIN: i32, const MAX: i32, const DEF: i32> ConstrainedI32<MIN, MAX, DEF> where
Guard<{ _ }>: Protect,
sourcepub const fn new(value: i32) -> Result<Self, ConstrainedI32Error<MIN, MAX>>
pub const fn new(value: i32) -> Result<Self, ConstrainedI32Error<MIN, MAX>>
Creates a new instance with provided value, if it satifies the range’s inclusive bounds. If the provided value is out of bounds, an error is returned, indicating which bound was violated.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let min = Constrained::new(-127)?;
assert_eq!(min.get(), -127);
let max = Constrained::new(126)?;
assert_eq!(max.get(), 126);
// Out of inclusive bounds.
assert!(Constrained::new(-128).is_err());
assert!(Constrained::new(127).is_err());
sourcepub const fn saturating_new(value: i32) -> Self
pub const fn saturating_new(value: i32) -> Self
Creates a new instance with provided value, if it satifies the range’s inclusive bounds. If provided value is out of bounds, the new instance is initialized with the value of the closest bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
// Below lower bound, so it constructs with lower bound value.
let min = Constrained::saturating_new(-128);
assert_eq!(min.get(), -127);
// Above upper bound, so it constructs with upper bound value.
let max = Constrained::saturating_new(127);
assert_eq!(max.get(), 126);
sourcepub const fn checked_new(value: i32) -> Option<Self>
pub const fn checked_new(value: i32) -> Option<Self>
Creates a new instance with provided value, if it satifies the range’s
inclusive bounds. If provided value is out of bounds, a None
is
returned.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let min = Constrained::checked_new(-127).unwrap();
assert_eq!(min.get(), -127);
let max = Constrained::checked_new(126).unwrap();
assert_eq!(max.get(), 126);
// Out of inclusive bounds.
assert_eq!(None, Constrained::checked_new(-128));
assert_eq!(None, Constrained::checked_new(127));
sourcepub const fn new_min() -> Self
pub const fn new_min() -> Self
Creates a new instance with the value defined by the range’s lower bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let min = Constrained::new_min();
assert_eq!(min.get(), -127);
sourcepub const fn new_max() -> Self
pub const fn new_max() -> Self
Creates a new instance with the value defined by the range’s upper bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let max = Constrained::new_max();
assert_eq!(max.get(), 126);
sourcepub const fn range() -> RangeInclusive<i32>
pub const fn range() -> RangeInclusive<i32>
Returns a [RangeInclusive]
value corresponding to the type’s bondaries.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let range = Constrained::range();
assert_eq!(Constrained::MIN, *range.start());
assert_eq!(Constrained::MAX, *range.end());
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> ConstrainedI32<MIN, MAX, DEF>
sourcepub fn set(&mut self, value: i32) -> Result<(), ConstrainedI32Error<MIN, MAX>>
pub fn set(&mut self, value: i32) -> Result<(), ConstrainedI32Error<MIN, MAX>>
Sets the contained value, if it satifies the range’s inclusive bounds. If the provided value is out of bounds, an error is returned, indicating which bound was violated.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::default();
assert_eq!(constrained.get(), -127);
constrained.set(126)?;
assert_eq!(constrained.get(), 126);
// Out of inclusive bounds.
assert!(constrained.set(-128).is_err());
assert!(constrained.set(127).is_err());
assert_eq!(constrained.get(), 126);
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> ConstrainedI32<MIN, MAX, DEF>
sourcepub const fn saturating_add(self, rhs: i32) -> Self
pub const fn saturating_add(self, rhs: i32) -> Self
Saturating integer addition. Computes self + rhs
, saturating the result
at the range’s inclusive bounds.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
// Saturates at upper bound.
constrained = constrained.saturating_add(1);
assert_eq!(constrained.get(), 126);
constrained = Constrained::new_min();
// Saturates at lower bound.
constrained = constrained.saturating_add(-1);
assert_eq!(constrained.get(), -127);
sourcepub const fn saturating_add_unsigned(self, rhs: u32) -> Self
pub const fn saturating_add_unsigned(self, rhs: u32) -> Self
Saturating addition with unsigned integer. Computes self + rhs
, saturating
the result at range’s upper bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
// Saturates at upper bound.
constrained = constrained.saturating_add_unsigned(1_u32);
assert_eq!(constrained.get(), 126);
sourcepub const fn saturating_sub(self, rhs: i32) -> Self
pub const fn saturating_sub(self, rhs: i32) -> Self
Saturating integer substraction. Computes self - rhs, saturating the result at the range’s inclusive bounds.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
// Saturates at lower bound.
constrained = constrained.saturating_sub(1);
assert_eq!(constrained.get(), -127);
constrained = Constrained::new_max();
// Saturates at upper bound.
constrained = constrained.saturating_sub(-1);
assert_eq!(constrained.get(), 126);
sourcepub const fn saturating_sub_unsigned(self, rhs: u32) -> Self
pub const fn saturating_sub_unsigned(self, rhs: u32) -> Self
Saturating substraction with unsigned integer. Computes self - rhs
,
saturating the result at range’s lower bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
// Saturates at the lower bound.
constrained = constrained.saturating_sub_unsigned(1_u32);
assert_eq!(constrained.get(), -127);
sourcepub const fn checked_add(self, rhs: i32) -> Option<Self>
pub const fn checked_add(self, rhs: i32) -> Option<Self>
Checked integer addition. Computes self + rhs
, returning None
if
result is out of the range’s inclusive bounds.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
// Above upper bound.
assert_eq!(constrained.checked_add(1), None);
constrained = Constrained::new_min();
// Below lower bound.
assert_eq!(constrained.checked_add(-1), None);
sourcepub const fn checked_add_unsigned(self, rhs: u32) -> Option<Self>
pub const fn checked_add_unsigned(self, rhs: u32) -> Option<Self>
Checked addition with unsigned integer. Computes self + rhs
, returning
None
if result is grater than the range’s upper bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
// Above upper bound.
assert_eq!(constrained.checked_add_unsigned(1_u32), None);
sourcepub const fn checked_sub(self, rhs: i32) -> Option<Self>
pub const fn checked_sub(self, rhs: i32) -> Option<Self>
Checked integer substraction. Computes self - rhs, returning None
if
result is out of the range’s inclusive bounds.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
// Below lower bound.
assert_eq!(constrained.checked_sub(1), None);
let mut constrained = Constrained::new_max();
// Above upper bound.
assert_eq!(constrained.checked_sub(-1), None);
sourcepub const fn checked_sub_unsigned(self, rhs: u32) -> Option<Self>
pub const fn checked_sub_unsigned(self, rhs: u32) -> Option<Self>
Checked substraction with unsigned integer. Computes self - rhs
, returning
None
if result is lower than the range’s lower bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
// Above upper bound.
assert_eq!(constrained.checked_sub_unsigned(1_u32), None);
sourcepub const fn try_add(
self,
rhs: i32
) -> Result<Self, ConstrainedI32Error<MIN, MAX>>
pub const fn try_add(
self,
rhs: i32
) -> Result<Self, ConstrainedI32Error<MIN, MAX>>
Fallible integer addition. Computes self + rhs
, returning an error
if the result is out of the range’s inclusive bounds.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
// Above upper bound.
assert!(constrained.try_add(1).is_err());
constrained = Constrained::new_min();
// Below lower bound.
assert!(constrained.try_add(-1).is_err());
sourcepub const fn try_add_unsigned(self, rhs: u32) -> Result<Self, MaxI32Error<MAX>>
pub const fn try_add_unsigned(self, rhs: u32) -> Result<Self, MaxI32Error<MAX>>
Fallible addition with unsigned. Computes self + rhs
, returning an error
if the result is greater than the range’s upper bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
// Above upper bound.
assert!(constrained.try_add_unsigned(1_u32).is_err());
sourcepub const fn try_sub(
self,
rhs: i32
) -> Result<Self, ConstrainedI32Error<MIN, MAX>>
pub const fn try_sub(
self,
rhs: i32
) -> Result<Self, ConstrainedI32Error<MIN, MAX>>
Fallible integer substraction. Computes self + rhs
, returning an error
if the result is out of the range’s inclusive bounds.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
// Below lower bound.
assert!(constrained.try_sub(1).is_err());
constrained = Constrained::new_max();
// Above upper bound.
assert!(constrained.try_sub(-1).is_err());
sourcepub const fn try_sub_unsigned(self, rhs: u32) -> Result<Self, MinI32Error<MIN>>
pub const fn try_sub_unsigned(self, rhs: u32) -> Result<Self, MinI32Error<MIN>>
Fallible substraction with unsigned. Computes self + rhs
, returning an
error if the result is lower than the range’s lower bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
// Below lower bound.
assert!(constrained.try_sub_unsigned(1_u32).is_err());
sourcepub const fn wrapping_add(self, rhs: i32) -> Self
pub const fn wrapping_add(self, rhs: i32) -> Self
Wrapping (modular) addition.
Computes self + rhs
, wrapping the result around the range’s upper bound
if the integer is positive, or at the range’s lower bound if negative.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
// Wraps around upper bound.
constrained = constrained.wrapping_add(1);
assert_eq!(constrained.get(), Constrained::MIN);
constrained = Constrained::new_min();
// Wraps around lower bound.
constrained = constrained.wrapping_add(-1);
assert_eq!(constrained.get(), Constrained::MAX);
sourcepub const fn wrapping_add_unsigned(self, rhs: u32) -> Self
pub const fn wrapping_add_unsigned(self, rhs: u32) -> Self
Wrapping (modular) addition with unsigned integer. Computes self + rhs
,
wrapping around at the range’s upper bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
// Wraps around upper bound.
constrained = constrained.wrapping_add_unsigned(1_u32);
assert_eq!(constrained.get(), Constrained::MIN);
sourcepub const fn wrapping_sub(self, rhs: i32) -> Self
pub const fn wrapping_sub(self, rhs: i32) -> Self
Wrapping (modular) substraction.
Computes self - rhs
, wrapping the result around the range’s upper bound
if the integer is negative, or at the range’s lower bound if positive.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
// Wraps around lower bound.
constrained = constrained.wrapping_sub(1);
assert_eq!(constrained.get(), Constrained::MAX);
constrained = Constrained::new_max();
// Wraps around upper bound.
constrained = constrained.wrapping_sub(-1);
assert_eq!(constrained.get(), Constrained::MIN);
sourcepub const fn wrapping_sub_unsigned(self, rhs: u32) -> Self
pub const fn wrapping_sub_unsigned(self, rhs: u32) -> Self
Wrapping (modular) substraction with unsigned integer. Computes self - rhs
,
wrapping around at the range’s lower bound.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
// Wraps around upper bound.
constrained = constrained.wrapping_sub_unsigned(1_u32);
assert_eq!(constrained.get(), Constrained::MAX);
sourcepub const fn overflowing_add(self, rhs: i32) -> (Self, bool)
pub const fn overflowing_add(self, rhs: i32) -> (Self, bool)
Wrapping (modular) addition, indicating if result was wrapped around.
Computes self + rhs
, wrapping the result around the range’s upper
bound if the integer is positive, or at the range’s lower bound if
negative. If a wrapping addition would have occurred, then the boolean
is set to true
, else to false
.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
let mut wrapped: bool;
// Wraps around the upper bound, the boolean is set to `true`.
(constrained, wrapped) = constrained.overflowing_add(2);
assert_eq!(constrained.get(), Constrained::MIN + 1);
assert_eq!(wrapped, true);
// Addition is within range bounds, the boolean is set to `false`.
(constrained, wrapped) = constrained.overflowing_add(-1);
assert_eq!(constrained.get(), Constrained::MIN);
assert_eq!(wrapped, false);
sourcepub const fn overflowing_add_unsigned(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_add_unsigned(self, rhs: u32) -> (Self, bool)
Wrapping (modular) addition with unsigned integer, indicating if result was wrapped around.
Computes self + rhs
, wrapping the result around the range’s upper
bound. If a wrapping addition would have occurred, then the boolean
is set to true
, else to false
.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
let mut wrapped: bool;
// Wraps around the upper bound, the boolean is set to `true`.
(constrained, wrapped) = constrained.overflowing_add_unsigned(1_u32);
assert_eq!(constrained.get(), Constrained::MIN);
assert_eq!(wrapped, true);
sourcepub const fn overflowing_sub(self, rhs: i32) -> (Self, bool)
pub const fn overflowing_sub(self, rhs: i32) -> (Self, bool)
Wrapping (modular) substraction, indicating if result was wrapped around.
Computes self - rhs
, wrapping the result around the range’s upper
bound if the integer is negative, or at the range’s lower bound if
positive. If a wrapping substraction would have occurred, then the boolean
is set to true
, else to false
.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
let mut wrapped: bool;
// Wraps around the lower bound, the boolean is set to `true`.
(constrained, wrapped) = constrained.overflowing_sub(2);
assert_eq!(constrained.get(), Constrained::MAX - 1);
assert_eq!(wrapped, true);
// Substraction is within range bounds, the boolean is set to `false`.
(constrained, wrapped) = constrained.overflowing_sub(-1);
assert_eq!(constrained.get(), Constrained::MAX);
assert_eq!(wrapped, false);
sourcepub const fn overflowing_sub_unsigned(self, rhs: u32) -> (Self, bool)
pub const fn overflowing_sub_unsigned(self, rhs: u32) -> (Self, bool)
Wrapping (modular) substraction with unsigned integer, indicating if result was wrapped around.
Computes self - rhs
, wrapping the result around the range’s lower
bound. If a wrapping addition would have occurred, then the boolean
is set to true
, else to false
.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
let mut wrapped: bool;
// Wraps around the upper bound, the boolean is set to `true`.
(constrained, wrapped) = constrained.overflowing_sub_unsigned(1_u32);
assert_eq!(constrained.get(), Constrained::MAX);
assert_eq!(wrapped, true);
sourcepub const fn signum(self) -> i32
pub const fn signum(self) -> i32
Returns a number representing sign of self
.
0
if the number is zero1
if the number is positive-1
if the number is negative
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
assert_eq!(constrained.signum(), -1);
constrained = Constrained::new_max();
assert_eq!(constrained.signum(), 1);
constrained.set(0).unwrap();
assert_eq!(constrained.signum(), 0);
sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true
if self
is negative and false
if the number is zero or
positive.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_min();
assert!(constrained.is_negative());
sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true
if self
is positive and false
if the number is zero or
negative.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-127, 126>;
let mut constrained = Constrained::new_max();
assert!(constrained.is_positive());
sourcepub const fn checked_abs(self) -> Option<Self>
pub const fn checked_abs(self) -> Option<Self>
Checked absolute value. Computes i32::abs()
,
returning None if it’s greater than MAX
.
Example
use constrained_int::i32::ConstrainedI32;
type Constrained = ConstrainedI32<-10, 8>;
let mut constrained = Constrained::new(-5).unwrap();
// Lower than `MAX`.
constrained = constrained.checked_abs().unwrap();
assert_eq!(constrained.get(), 5);
// Greater than `MAX`.
constrained.set(-9).unwrap();
assert_eq!(constrained.checked_abs(), None);
Trait Implementations
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> Clone for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> Clone for ConstrainedI32<MIN, MAX, DEF>
sourcefn clone(&self) -> ConstrainedI32<MIN, MAX, DEF>
fn clone(&self) -> ConstrainedI32<MIN, MAX, DEF>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> Default for ConstrainedI32<MIN, MAX, DEF> where
Guard<{ _ }>: Protect,
impl<const MIN: i32, const MAX: i32, const DEF: i32> Default for ConstrainedI32<MIN, MAX, DEF> where
Guard<{ _ }>: Protect,
sourceimpl<'de, const MIN: i32, const MAX: i32, const DEF: i32> Deserialize<'de> for ConstrainedI32<MIN, MAX, DEF>
impl<'de, const MIN: i32, const MAX: i32, const DEF: i32> Deserialize<'de> for ConstrainedI32<MIN, MAX, DEF>
sourcefn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> Display for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> Display for ConstrainedI32<MIN, MAX, DEF>
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> LowerHex for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> LowerHex for ConstrainedI32<MIN, MAX, DEF>
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> Ord for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> Ord for ConstrainedI32<MIN, MAX, DEF>
sourcefn cmp(&self, other: &ConstrainedI32<MIN, MAX, DEF>) -> Ordering
fn cmp(&self, other: &ConstrainedI32<MIN, MAX, DEF>) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Self where
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> PartialEq<ConstrainedI32<MIN, MAX, DEF>> for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> PartialEq<ConstrainedI32<MIN, MAX, DEF>> for ConstrainedI32<MIN, MAX, DEF>
sourcefn eq(&self, other: &ConstrainedI32<MIN, MAX, DEF>) -> bool
fn eq(&self, other: &ConstrainedI32<MIN, MAX, DEF>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ConstrainedI32<MIN, MAX, DEF>) -> bool
fn ne(&self, other: &ConstrainedI32<MIN, MAX, DEF>) -> bool
This method tests for !=
.
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> PartialOrd<ConstrainedI32<MIN, MAX, DEF>> for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> PartialOrd<ConstrainedI32<MIN, MAX, DEF>> for ConstrainedI32<MIN, MAX, DEF>
sourcefn partial_cmp(&self, other: &ConstrainedI32<MIN, MAX, DEF>) -> Option<Ordering>
fn partial_cmp(&self, other: &ConstrainedI32<MIN, MAX, DEF>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> RangeBounds<i32> for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> RangeBounds<i32> for ConstrainedI32<MIN, MAX, DEF>
sourcefn start_bound(&self) -> Bound<&i32>
fn start_bound(&self) -> Bound<&i32>
Start index bound. Read more
1.35.0 · sourcefn contains<U>(&self, item: &U) -> bool where
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,
fn contains<U>(&self, item: &U) -> bool where
T: PartialOrd<U>,
U: PartialOrd<T> + ?Sized,
Returns true
if item
is contained in the range. Read more
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> Serialize for ConstrainedI32<MIN, MAX, DEF>
Available on crate feature serde
only.
impl<const MIN: i32, const MAX: i32, const DEF: i32> Serialize for ConstrainedI32<MIN, MAX, DEF>
serde
only.sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> TryFrom<i32> for ConstrainedI32<MIN, MAX, DEF> where
Guard<{ _ }>: Protect,
impl<const MIN: i32, const MAX: i32, const DEF: i32> TryFrom<i32> for ConstrainedI32<MIN, MAX, DEF> where
Guard<{ _ }>: Protect,
sourceimpl<const MIN: i32, const MAX: i32, const DEF: i32> UpperHex for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> UpperHex for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> Copy for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> Eq for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> StructuralEq for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> StructuralPartialEq for ConstrainedI32<MIN, MAX, DEF>
Auto Trait Implementations
impl<const MIN: i32, const MAX: i32, const DEF: i32> RefUnwindSafe for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> Send for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> Sync for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> Unpin for ConstrainedI32<MIN, MAX, DEF>
impl<const MIN: i32, const MAX: i32, const DEF: i32> UnwindSafe for ConstrainedI32<MIN, MAX, DEF>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more