Equal
Equal
is a type that signifies the target is equal to a certain number.
type Age = EqualU8<18>;
fn equal_example() -> Result<(), Error<u8>> {
let age = Age::new(18)?;
assert_eq!(age.into_value(), 18);
let age = Age::new(19);
assert!(age.is_err());
Ok(())
}
Less
Less
is a type that signifies the target is less than a certain number.
type Age = LessU8<80>;
fn less_example() -> Result<(), Error<u8>> {
let age = Age::new(79)?;
assert_eq!(age.into_value(), 79);
let age = Age::new(80);
assert!(age.is_err());
Ok(())
}
Greater
Greater
is a type that signifies the target is greater than a certain number.
type Age = GreaterU8<18>;
fn greater_example() -> Result<(), Error<u8>> {
let age = Age::new(19)?;
assert_eq!(age.into_value(), 19);
let age = Age::new(18);
assert!(age.is_err());
Ok(())
}
MinMax
MinMax
is a type that signifies the target exists between a certain number and another number.
type Age = MinMaxU8<18, 80>;
fn min_max_example() -> Result<(), Error<u8>> {
let age = Age::new(18)?;
assert_eq!(age.into_value(), 18);
let age = Age::new(80)?;
assert_eq!(age.into_value(), 80);
let age = Age::new(17);
assert!(age.is_err());
let age = Age::new(81);
assert!(age.is_err());
Ok(())
}
Even
Even
is a type that signifies the target is an even number.
fn even_example() -> Result<(), Error<u8>> {
let even = EvenU8::new(2)?;
assert_eq!(even.into_value(), 2);
let even = EvenU8::new(3);
assert!(even.is_err());
Ok(())
}
Odd
Odd
is a type that signifies the target is an odd number.
fn odd_example() -> Result<(), Error<u8>> {
let odd = OddU8::new(3)?;
assert_eq!(odd.into_value(), 3);
let odd = OddU8::new(2);
assert!(odd.is_err());
Ok(())
}
LessEqual
COMING SOON…
println!("COMING SOON...");
GreaterEqual
COMING SOON…
println!("COMING SOON...");