pub struct RangedInteger<const MIN: i32, const MAX: i32> { /* private fields */ }Expand description
A simple struct for wrapping an i32 with const generic parameters to limit
the range of allowed values.
Implementations§
Source§impl<const MIN: i32, const MAX: i32> RangedInteger<MIN, MAX>
impl<const MIN: i32, const MAX: i32> RangedInteger<MIN, MAX>
Sourcepub fn new(value: i32) -> Self
pub fn new(value: i32) -> Self
Makes a new ranged integer if the value is in the allowed range, otherwise panics.
Sourcepub fn range() -> RangeInclusive<i32>
pub fn range() -> RangeInclusive<i32>
Gets the range of allowed values as an inclusive range, constructed from the generic parameters.
Sourcepub fn random_value() -> i32
pub fn random_value() -> i32
Gets a random value that is in the range of allowed values.
Trait Implementations§
Source§impl<const MIN: i32, const MAX: i32> Clone for RangedInteger<MIN, MAX>
impl<const MIN: i32, const MAX: i32> Clone for RangedInteger<MIN, MAX>
Source§fn clone(&self) -> RangedInteger<MIN, MAX>
fn clone(&self) -> RangedInteger<MIN, MAX>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<const MIN: i32, const MAX: i32> Copy for RangedInteger<MIN, MAX>
impl<const MIN: i32, const MAX: i32> StructuralPartialEq for RangedInteger<MIN, MAX>
Auto Trait Implementations§
impl<const MIN: i32, const MAX: i32> Freeze for RangedInteger<MIN, MAX>
impl<const MIN: i32, const MAX: i32> RefUnwindSafe for RangedInteger<MIN, MAX>
impl<const MIN: i32, const MAX: i32> Send for RangedInteger<MIN, MAX>
impl<const MIN: i32, const MAX: i32> Sync for RangedInteger<MIN, MAX>
impl<const MIN: i32, const MAX: i32> Unpin for RangedInteger<MIN, MAX>
impl<const MIN: i32, const MAX: i32> UnwindSafe for RangedInteger<MIN, MAX>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more