pub struct Range<const MIN: i128, const MAX: i128>;Expand description
Requires an integer to be in a range.
Both ends are inclusive. The code of the violation is the name of the
validator: range, min (Min) or max (Max). It has the
parameters min and max (if they are set).
use deser_validate::{Min, Range, Validator};
assert!(Range::<1, 65535>::validate(&80u16).is_ok());
assert_eq!(
Range::<1, 65535>::validate(&0u16).unwrap_err().message(),
"must be between 1 and 65535"
);
assert!(Min::<1>::validate(&0u32).is_err());Trait Implementations§
Auto Trait Implementations§
impl<const MIN: i128, const MAX: i128> Freeze for Range<MIN, MAX>
impl<const MIN: i128, const MAX: i128> RefUnwindSafe for Range<MIN, MAX>
impl<const MIN: i128, const MAX: i128> Send for Range<MIN, MAX>
impl<const MIN: i128, const MAX: i128> Sync for Range<MIN, MAX>
impl<const MIN: i128, const MAX: i128> Unpin for Range<MIN, MAX>
impl<const MIN: i128, const MAX: i128> UnsafeUnpin for Range<MIN, MAX>
impl<const MIN: i128, const MAX: i128> UnwindSafe for Range<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