Trait range_check::Check
[−]
[src]
pub trait Check<R>: Sized { fn check_range(self, range: R) -> Result<Self>; }
Trait that provides early returns for failed range checks using Result
s.
Required Methods
fn check_range(self, range: R) -> Result<Self>
Checks whether self
is within the given range. If it is, re-returns
self
. Otherwise, returns an Error
that contains both the value and
the range.
Because it has to return at least part of them, this method consumes
both self
and the range.
Examples
use range_check::Check; assert!(24680.check_range(1..99999).is_ok()); assert!(24680.check_range(1..9999).is_err());