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).

Associated Types

bool for scalars, or vector of bools for vectors.

Required methods

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

Returns whether this value is between 0 and 1 (inclusive).

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.

Implementations on Foreign Types

Implementors