pub trait IsBetween<Bound = Self>: Sized {
type Output;
fn is_between(self, lower: Bound, upper: Bound) -> Self::Output;
fn is_between01(self) -> Self::Output
where
Bound: Zero + One,
{ ... }
fn is_between_inclusive_range_bounds(
self,
range: RangeInclusive<Bound>
) -> Self::Output { ... }
}
Expand description
A value that can tell whether or not it is between two bounds (inclusive).
Required Associated Types
Required Methods
fn is_between(self, lower: Bound, upper: Bound) -> Self::Output
fn is_between(self, lower: Bound, upper: Bound) -> Self::Output
Returns whether this value is between lower
and upper
(inclusive).
Panics
Panics if lower
is greater than upper
. Swap the values yourself if necessary.
use vek::ops::IsBetween;
assert!(5_i32 .is_between(5, 10));
assert!(7_i32 .is_between(5, 10));
assert!(10_i32.is_between(5, 10));
assert!(!(4_i32 .is_between(5, 10)));
assert!(!(11_i32.is_between(5, 10)));
Provided Methods
fn is_between01(self) -> Self::Output where
Bound: Zero + One,
fn is_between01(self) -> Self::Output where
Bound: Zero + One,
Returns whether this value is between 0 and 1 (inclusive).
fn is_between_inclusive_range_bounds(
self,
range: RangeInclusive<Bound>
) -> Self::Output
fn is_between_inclusive_range_bounds(
self,
range: RangeInclusive<Bound>
) -> Self::Output
Returns whether this value is between the lower and upper bounds of this inclusive range.
This is redundant with RangeInclusive::contains()
, but is still useful for generics that use the IsBetween
trait.