[][src]Struct bounded_integer::examples::BoundedStruct

pub struct BoundedStruct(_);

A bounded struct, implemented as a protected newtype.

This was generated from:

#[repr(i8)]
pub struct BoundedStruct { -8..8 }

Implementations

impl BoundedStruct[src]

pub const MIN_VALUE: i8[src]

The smallest value that this bounded integer can contain.

pub const MAX_VALUE: i8[src]

The largest value that this bounded integer can contain.

pub const MIN: Self[src]

The smallest value of the bounded integer.

pub const MAX: Self[src]

The largest value of the bounded integer.

pub const RANGE: i8[src]

The number of values the bounded integer can contain.

#[must_use]pub unsafe fn new_unchecked(n: i8) -> Self[src]

Creates a bounded integer without checking the value.

Safety

The value must not be outside the valid range of values; it must not be less than MIN or greater than MAX.

#[must_use]pub fn in_range(n: i8) -> bool[src]

Checks whether the given value is in the range of the bounded integer.

#[must_use]pub fn new(n: i8) -> Option<Self>[src]

Creates a bounded integer if the given value is within the range [MIN, MAX].

#[must_use]pub fn new_saturating(n: i8) -> Self[src]

Creates a bounded integer by setting the value to MIN or MAX if it is too low or too high respectively.

#[must_use]pub fn new_wrapping(n: i8) -> Self[src]

Creates a bounded integer by using modulo arithmetic. Values in the range won't be changed but values outside will be wrapped around.

#[must_use]pub fn get(self) -> i8[src]

Gets the value of the bounded integer as a primitive type.

#[must_use]pub fn abs(self) -> Self[src]

Computes the absolute value of self, panicking if it is out of range.

#[must_use]pub fn pow(self, exp: u32) -> Self[src]

Raises self to the power of exp, using exponentiation by squaring. Panics if it is out of range.

#[must_use]pub fn div_euclid(self, rhs: i8) -> Self[src]

Calculates the quotient of Euclidean division of self by rhs. Panics if rhs is 0 or the result is out of range.

#[must_use]pub fn rem_euclid(self, rhs: i8) -> Self[src]

Calculates the least nonnegative remainder of self (mod rhs). Panics if rhs is 0 or the result is out of range.

#[must_use]pub fn checked_add(self, rhs: i8) -> Option<Self>[src]

Checked integer addition.

#[must_use]pub fn saturating_add(self, rhs: i8) -> Self[src]

Saturing integer addition.

#[must_use]pub fn checked_sub(self, rhs: i8) -> Option<Self>[src]

Checked integer subtraction.

#[must_use]pub fn saturating_sub(self, rhs: i8) -> Self[src]

Saturing integer subtraction.

#[must_use]pub fn checked_mul(self, rhs: i8) -> Option<Self>[src]

Checked integer multiplication.

#[must_use]pub fn saturating_mul(self, rhs: i8) -> Self[src]

Saturing integer multiplication.

#[must_use]pub fn checked_div(self, rhs: i8) -> Option<Self>[src]

Checked integer division.

#[must_use]pub fn checked_div_euclid(self, rhs: i8) -> Option<Self>[src]

Checked Euclidean division.

#[must_use]pub fn checked_rem(self, rhs: i8) -> Option<Self>[src]

Checked integer remainder.

#[must_use]pub fn checked_rem_euclid(self, rhs: i8) -> Option<Self>[src]

Checked Euclidean remainder.

#[must_use]pub fn checked_neg(self) -> Option<Self>[src]

Checked negation.

#[must_use]pub fn checked_abs(self) -> Option<Self>[src]

Checked absolute value.

#[must_use]pub fn checked_pow(self, rhs: u32) -> Option<Self>[src]

Checked exponentiation.

#[must_use]pub fn saturating_pow(self, rhs: u32) -> Self[src]

Saturing exponentiation.

Trait Implementations

impl<'b> Add<&'b BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the + operator.

impl<'b, 'a> Add<&'b BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the + operator.

impl<'b> Add<&'b i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the + operator.

impl<'b, 'a> Add<&'b i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the + operator.

impl Add<BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the + operator.

impl<'a> Add<BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the + operator.

impl Add<i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the + operator.

impl<'a> Add<i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the + operator.

impl<'a> AddAssign<&'a BoundedStruct> for BoundedStruct[src]

impl<'a> AddAssign<&'a i8> for BoundedStruct[src]

impl AddAssign<BoundedStruct> for BoundedStruct[src]

impl AddAssign<i8> for BoundedStruct[src]

impl Binary for BoundedStruct[src]

impl Clone for BoundedStruct[src]

impl Copy for BoundedStruct[src]

impl Debug for BoundedStruct[src]

impl Display for BoundedStruct[src]

impl<'b> Div<&'b BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the / operator.

impl<'b, 'a> Div<&'b BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the / operator.

impl<'b> Div<&'b i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the / operator.

impl<'b, 'a> Div<&'b i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the / operator.

impl Div<BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the / operator.

impl<'a> Div<BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the / operator.

impl Div<i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the / operator.

impl<'a> Div<i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the / operator.

impl<'a> DivAssign<&'a BoundedStruct> for BoundedStruct[src]

impl<'a> DivAssign<&'a i8> for BoundedStruct[src]

impl DivAssign<BoundedStruct> for BoundedStruct[src]

impl DivAssign<i8> for BoundedStruct[src]

impl Eq for BoundedStruct[src]

impl Hash for BoundedStruct[src]

impl LowerExp for BoundedStruct[src]

impl LowerHex for BoundedStruct[src]

impl<'b> Mul<&'b BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the * operator.

impl<'b, 'a> Mul<&'b BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the * operator.

impl<'b> Mul<&'b i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the * operator.

impl<'b, 'a> Mul<&'b i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the * operator.

impl Mul<BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the * operator.

impl<'a> Mul<BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the * operator.

impl Mul<i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the * operator.

impl<'a> Mul<i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the * operator.

impl<'a> MulAssign<&'a BoundedStruct> for BoundedStruct[src]

impl<'a> MulAssign<&'a i8> for BoundedStruct[src]

impl MulAssign<BoundedStruct> for BoundedStruct[src]

impl MulAssign<i8> for BoundedStruct[src]

impl Neg for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl<'a> Neg for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl Octal for BoundedStruct[src]

impl Ord for BoundedStruct[src]

impl PartialEq<BoundedStruct> for BoundedStruct[src]

impl PartialOrd<BoundedStruct> for BoundedStruct[src]

impl<'b> Rem<&'b BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the % operator.

impl<'b, 'a> Rem<&'b BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the % operator.

impl<'b> Rem<&'b i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the % operator.

impl<'b, 'a> Rem<&'b i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the % operator.

impl Rem<BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the % operator.

impl<'a> Rem<BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the % operator.

impl Rem<i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the % operator.

impl<'a> Rem<i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the % operator.

impl<'a> RemAssign<&'a BoundedStruct> for BoundedStruct[src]

impl<'a> RemAssign<&'a i8> for BoundedStruct[src]

impl RemAssign<BoundedStruct> for BoundedStruct[src]

impl RemAssign<i8> for BoundedStruct[src]

impl StructuralEq for BoundedStruct[src]

impl StructuralPartialEq for BoundedStruct[src]

impl<'b> Sub<&'b BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl<'b, 'a> Sub<&'b BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl<'b> Sub<&'b i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl<'b, 'a> Sub<&'b i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl Sub<BoundedStruct> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl<'a> Sub<BoundedStruct> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl Sub<i8> for BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl<'a> Sub<i8> for &'a BoundedStruct[src]

type Output = BoundedStruct

The resulting type after applying the - operator.

impl<'a> SubAssign<&'a BoundedStruct> for BoundedStruct[src]

impl<'a> SubAssign<&'a i8> for BoundedStruct[src]

impl SubAssign<BoundedStruct> for BoundedStruct[src]

impl SubAssign<i8> for BoundedStruct[src]

impl UpperExp for BoundedStruct[src]

impl UpperHex for BoundedStruct[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.