Trait IsBetween

Source
pub trait IsBetween<Bound = Self>: Sized {
    type Output;

    // Required method
    fn is_between(self, lower: Bound, upper: Bound) -> Self::Output;

    // Provided methods
    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§

Source

type Output

bool for scalars, or vector of bools for vectors.

Required Methods§

Source

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§

Source

fn is_between01(self) -> Self::Output
where Bound: Zero + One,

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

Source

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl IsBetween for f32

Source§

type Output = bool

Source§

fn is_between(self, lower: f32, upper: f32) -> bool

Source§

impl IsBetween for f64

Source§

type Output = bool

Source§

fn is_between(self, lower: f64, upper: f64) -> bool

Source§

impl IsBetween for i8

Source§

type Output = bool

Source§

fn is_between(self, lower: i8, upper: i8) -> bool

Source§

impl IsBetween for i16

Source§

type Output = bool

Source§

fn is_between(self, lower: i16, upper: i16) -> bool

Source§

impl IsBetween for i32

Source§

type Output = bool

Source§

fn is_between(self, lower: i32, upper: i32) -> bool

Source§

impl IsBetween for i64

Source§

type Output = bool

Source§

fn is_between(self, lower: i64, upper: i64) -> bool

Source§

impl IsBetween for isize

Source§

type Output = bool

Source§

fn is_between(self, lower: isize, upper: isize) -> bool

Source§

impl IsBetween for u8

Source§

type Output = bool

Source§

fn is_between(self, lower: u8, upper: u8) -> bool

Source§

impl IsBetween for u16

Source§

type Output = bool

Source§

fn is_between(self, lower: u16, upper: u16) -> bool

Source§

impl IsBetween for u32

Source§

type Output = bool

Source§

fn is_between(self, lower: u32, upper: u32) -> bool

Source§

impl IsBetween for u64

Source§

type Output = bool

Source§

fn is_between(self, lower: u64, upper: u64) -> bool

Source§

impl IsBetween for usize

Source§

type Output = bool

Source§

fn is_between(self, lower: usize, upper: usize) -> bool

Source§

impl IsBetween for Wrapping<i8>

Source§

type Output = bool

Source§

fn is_between(self, lower: Wrapping<i8>, upper: Wrapping<i8>) -> bool

Source§

impl IsBetween for Wrapping<i16>

Source§

type Output = bool

Source§

fn is_between(self, lower: Wrapping<i16>, upper: Wrapping<i16>) -> bool

Source§

impl IsBetween for Wrapping<i32>

Source§

type Output = bool

Source§

fn is_between(self, lower: Wrapping<i32>, upper: Wrapping<i32>) -> bool

Source§

impl IsBetween for Wrapping<i64>

Source§

type Output = bool

Source§

fn is_between(self, lower: Wrapping<i64>, upper: Wrapping<i64>) -> bool

Source§

impl IsBetween for Wrapping<isize>

Source§

impl IsBetween for Wrapping<u8>

Source§

type Output = bool

Source§

fn is_between(self, lower: Wrapping<u8>, upper: Wrapping<u8>) -> bool

Source§

impl IsBetween for Wrapping<u16>

Source§

type Output = bool

Source§

fn is_between(self, lower: Wrapping<u16>, upper: Wrapping<u16>) -> bool

Source§

impl IsBetween for Wrapping<u32>

Source§

type Output = bool

Source§

fn is_between(self, lower: Wrapping<u32>, upper: Wrapping<u32>) -> bool

Source§

impl IsBetween for Wrapping<u64>

Source§

type Output = bool

Source§

fn is_between(self, lower: Wrapping<u64>, upper: Wrapping<u64>) -> bool

Source§

impl IsBetween for Wrapping<usize>

Implementors§

Source§

impl<T> IsBetween for Extent2<T>
where T: IsBetween<Output = bool>,

Source§

impl<T> IsBetween for Extent3<T>
where T: IsBetween<Output = bool>,

Source§

impl<T> IsBetween for Rgb<T>
where T: IsBetween<Output = bool>,

Source§

impl<T> IsBetween for Rgba<T>
where T: IsBetween<Output = bool>,

Source§

impl<T> IsBetween for Vec2<T>
where T: IsBetween<Output = bool>,

Source§

impl<T> IsBetween for Vec3<T>
where T: IsBetween<Output = bool>,

Source§

impl<T> IsBetween for Vec4<T>
where T: IsBetween<Output = bool>,

Source§

impl<T> IsBetween<T> for Extent2<T>
where T: IsBetween<Output = bool> + Copy,

Source§

impl<T> IsBetween<T> for Extent3<T>
where T: IsBetween<Output = bool> + Copy,

Source§

impl<T> IsBetween<T> for Rgb<T>
where T: IsBetween<Output = bool> + Copy,

Source§

impl<T> IsBetween<T> for Rgba<T>
where T: IsBetween<Output = bool> + Copy,

Source§

impl<T> IsBetween<T> for Vec2<T>
where T: IsBetween<Output = bool> + Copy,

Source§

impl<T> IsBetween<T> for Vec3<T>
where T: IsBetween<Output = bool> + Copy,

Source§

impl<T> IsBetween<T> for Vec4<T>
where T: IsBetween<Output = bool> + Copy,