InRangeInclusive

Struct InRangeInclusive 

Source
pub struct InRangeInclusive<A: Unsigned, B>
where B: Sub<A> + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,
{ /* private fields */ }
Expand description

A usize value that is guaranteed to be in the range A..=B.

Common methods are in the InRangeBounds trait implementation.

Trait Implementations§

Source§

impl<A: Clone + Unsigned, B> Clone for InRangeInclusive<A, B>
where B: Sub<A> + Clone + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,

Source§

fn clone(&self) -> InRangeInclusive<A, B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug + Unsigned, B> Debug for InRangeInclusive<A, B>
where B: Sub<A> + Debug + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<A: Unsigned, B> Finite for InRangeInclusive<A, B>
where B: Sub<A> + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength + FitsInUsize,

Source§

type INHABITANTS = <InRangeInclusive<A, B> as InRangeBounds>::INHABITANTS

The total number of different inhabitants of the type. Read more
Source§

fn to_usize(&self) -> usize

Should return a number in the range 0..INHABITANTS.
Source§

fn from_usize(i: usize) -> Option<Self>

Should be the inverse function of to_usize. Read more
Source§

impl<A: Hash + Unsigned, B> Hash for InRangeInclusive<A, B>
where B: Sub<A> + Hash + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<A: Unsigned, B> InRangeBounds for InRangeInclusive<A, B>
where B: Sub<A> + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength + FitsInUsize,

Source§

type MIN = A

The smallest value representable (if INHABITANTS is non-zero).
Source§

type INHABITANTS = <<B as Sub<A>>::Output as Add<B1>>::Output

The number of values representable.
Source§

unsafe fn new_unchecked(i: usize) -> Self

Creates a value without checking whether the value is in range. This results in undefined behavior if the value is not in range. Read more
Source§

fn get(self) -> usize

Returns the value as a usize.
Source§

fn new_from_start_offset(offset: usize) -> Option<Self>

Same as InRangeBounds::new(Self::MIN + i).
Source§

fn offset_from_start(i: usize) -> Option<usize>

Returns the offset from Self::MIN if i is in range.
Source§

fn in_bounds(i: usize) -> bool

Returns whether i is in range.
Source§

fn new(i: usize) -> Option<Self>

Creates a value if the given value is in range.
Source§

impl<A: Ord + Unsigned, B> Ord for InRangeInclusive<A, B>
where B: Sub<A> + Ord + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,

Source§

fn cmp(&self, other: &InRangeInclusive<A, B>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<A: PartialEq + Unsigned, B> PartialEq for InRangeInclusive<A, B>
where B: Sub<A> + PartialEq + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,

Source§

fn eq(&self, other: &InRangeInclusive<A, B>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<A: PartialOrd + Unsigned, B> PartialOrd for InRangeInclusive<A, B>
where B: Sub<A> + PartialOrd + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,

Source§

fn partial_cmp(&self, other: &InRangeInclusive<A, B>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<A: Copy + Unsigned, B> Copy for InRangeInclusive<A, B>
where B: Sub<A> + Copy + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,

Source§

impl<A: Eq + Unsigned, B> Eq for InRangeInclusive<A, B>
where B: Sub<A> + Eq + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,

Source§

impl<A: Unsigned, B> StructuralPartialEq for InRangeInclusive<A, B>
where B: Sub<A> + Unsigned, <B as Sub<A>>::Output: Add<B1>, <<B as Sub<A>>::Output as Add<B1>>::Output: ArrayLength,

Auto Trait Implementations§

§

impl<A, B> Freeze for InRangeInclusive<A, B>
where <<B as Sub<A>>::Output as Add<B1>>::Output: Sized,

§

impl<A, B> RefUnwindSafe for InRangeInclusive<A, B>
where <<B as Sub<A>>::Output as Add<B1>>::Output: Sized, A: RefUnwindSafe, B: RefUnwindSafe,

§

impl<A, B> Send for InRangeInclusive<A, B>
where <<B as Sub<A>>::Output as Add<B1>>::Output: Sized, A: Send, B: Send,

§

impl<A, B> Sync for InRangeInclusive<A, B>
where <<B as Sub<A>>::Output as Add<B1>>::Output: Sized, A: Sync, B: Sync,

§

impl<A, B> Unpin for InRangeInclusive<A, B>
where <<B as Sub<A>>::Output as Add<B1>>::Output: Sized, A: Unpin, B: Unpin,

§

impl<A, B> UnwindSafe for InRangeInclusive<A, B>
where <<B as Sub<A>>::Output as Add<B1>>::Output: Sized, A: UnwindSafe, B: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> FiniteExt for T
where T: Finite,

Source§

fn iter_all() -> IterAll<Self>

An iterator over all inhabitants of the type, ordered by the order provided by Finite.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.