Struct ux::u2
[−]
[src]
pub struct u2(_);
The 2-bit unsigned integer type.
Methods
impl u2[src]
impl u2[src]
pub fn min_value() -> u2[src]
Returns the smallest value that can be represented by this integer type.
pub fn max_value() -> u2[src]
Returns the largest value that can be represented by this integer type.
pub fn new(value: u8) -> u2[src]
Crates a new variable
This function mainly exists as there is currently not a better way to construct these types. May be deprecated or removed if a better way to construct these types becomes available.
Examples
Basic usage:
use ux::*; assert_eq!(u31::new(64), u31::from(64u8));
Panic
This function will panic if value is not representable by this type
pub fn wrapping_sub(self, rhs: Self) -> Self[src]
Wrapping (modular) subtraction. Computes self - other,
wrapping around at the boundary of the type.
Examples
Basic usage:
use ux::*; assert_eq!(i5::MIN.wrapping_sub(i5::new(1)), i5::MAX); assert_eq!(i5::new(-10).wrapping_sub(i5::new(5)), i5::new(-15)); assert_eq!(i5::new(-15).wrapping_sub(i5::new(5)), i5::new(12));
pub fn wrapping_add(self, rhs: Self) -> Self[src]
Wrapping (modular) addition. Computes self + other,
wrapping around at the boundary of the type.
Examples
Basic usage:
use ux::*; assert_eq!(i5::MAX.wrapping_add(i5::new(1)), i5::MIN); assert_eq!(i5::new(10).wrapping_add(i5::new(5)), i5::new(15)); assert_eq!(i5::new(15).wrapping_add(i5::new(5)), i5::new(-12));
Trait Implementations
impl From<u2> for u8[src]
impl From<u2> for u16[src]
impl From<u2> for u32[src]
impl From<u2> for u64[src]
impl From<u2> for u3[src]
impl From<u2> for u4[src]
impl From<u2> for u5[src]
impl From<u2> for u6[src]
impl From<u2> for u7[src]
impl From<u2> for u9[src]
impl From<u2> for u10[src]
impl From<u2> for u11[src]
impl From<u2> for u12[src]
impl From<u2> for u13[src]
impl From<u2> for u14[src]
impl From<u2> for u15[src]
impl From<u2> for u17[src]
impl From<u2> for u18[src]
impl From<u2> for u19[src]
impl From<u2> for u20[src]
impl From<u2> for u21[src]
impl From<u2> for u22[src]
impl From<u2> for u23[src]
impl From<u2> for u24[src]
impl From<u2> for u25[src]
impl From<u2> for u26[src]
impl From<u2> for u27[src]
impl From<u2> for u28[src]
impl From<u2> for u29[src]
impl From<u2> for u30[src]
impl From<u2> for u31[src]
impl From<u2> for u33[src]
impl From<u2> for u34[src]
impl From<u2> for u35[src]
impl From<u2> for u36[src]
impl From<u2> for u37[src]
impl From<u2> for u38[src]
impl From<u2> for u39[src]
impl From<u2> for u40[src]
impl From<u2> for u41[src]
impl From<u2> for u42[src]
impl From<u2> for u43[src]
impl From<u2> for u44[src]
impl From<u2> for u45[src]
impl From<u2> for u46[src]
impl From<u2> for u47[src]
impl From<u2> for u48[src]
impl From<u2> for u49[src]
impl From<u2> for u50[src]
impl From<u2> for u51[src]
impl From<u2> for u52[src]
impl From<u2> for u53[src]
impl From<u2> for u54[src]
impl From<u2> for u55[src]
impl From<u2> for u56[src]
impl From<u2> for u57[src]
impl From<u2> for u58[src]
impl From<u2> for u59[src]
impl From<u2> for u60[src]
impl From<u2> for u61[src]
impl From<u2> for u62[src]
impl From<u2> for u63[src]
impl Default for u2[src]
impl Clone for u2[src]
fn clone(&self) -> u2[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Copy for u2[src]
impl Debug for u2[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl PartialEq for u2[src]
fn eq(&self, other: &Self) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl Eq for u2[src]
impl PartialOrd for u2[src]
fn partial_cmp(&self, other: &u2) -> Option<Ordering>[src]
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Ord for u2[src]
fn cmp(&self, other: &u2) -> Ordering[src]
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Hash for u2[src]
fn hash<H: Hasher>(&self, h: &mut H)[src]
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl Display for u2[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
Formats the value using the given formatter. Read more
impl UpperHex for u2[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
Formats the value using the given formatter.
impl LowerHex for u2[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
Formats the value using the given formatter.
impl Octal for u2[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
Formats the value using the given formatter.
impl Binary for u2[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
Formats the value using the given formatter.
impl<T> Shr<T> for u2 where
u8: Shr<T, Output = u8>, [src]
u8: Shr<T, Output = u8>,
type Output = u2
The resulting type after applying the >> operator.
fn shr(self, rhs: T) -> u2[src]
Performs the >> operation.
impl<T> Shl<T> for u2 where
u8: Shl<T, Output = u8>, [src]
u8: Shl<T, Output = u8>,
type Output = u2
The resulting type after applying the << operator.
fn shl(self, rhs: T) -> u2[src]
Performs the << operation.
impl<T> ShrAssign<T> for u2 where
u8: ShrAssign<T>, [src]
u8: ShrAssign<T>,
fn shr_assign(&mut self, rhs: T)[src]
Performs the >>= operation.
impl<T> ShlAssign<T> for u2 where
u8: ShlAssign<T>, [src]
u8: ShlAssign<T>,
fn shl_assign(&mut self, rhs: T)[src]
Performs the <<= operation.
impl BitOr<u2> for u2[src]
type Output = u2
The resulting type after applying the | operator.
fn bitor(self, rhs: u2) -> Self::Output[src]
Performs the | operation.
impl<'a> BitOr<&'a u2> for u2[src]
type Output = <u2 as BitOr<u2>>::Output
The resulting type after applying the | operator.
fn bitor(self, rhs: &'a u2) -> Self::Output[src]
Performs the | operation.
impl<'a> BitOr<u2> for &'a u2[src]
type Output = <u2 as BitOr<u2>>::Output
The resulting type after applying the | operator.
fn bitor(self, rhs: u2) -> Self::Output[src]
Performs the | operation.
impl<'a> BitOr<&'a u2> for &'a u2[src]
type Output = <u2 as BitOr<u2>>::Output
The resulting type after applying the | operator.
fn bitor(self, rhs: &'a u2) -> Self::Output[src]
Performs the | operation.
impl BitOrAssign<u2> for u2[src]
fn bitor_assign(&mut self, other: u2)[src]
Performs the |= operation.
impl BitAnd<u2> for u2[src]
type Output = u2
The resulting type after applying the & operator.
fn bitand(self, rhs: u2) -> Self::Output[src]
Performs the & operation.
impl<'a> BitAnd<&'a u2> for u2[src]
type Output = <u2 as BitOr<u2>>::Output
The resulting type after applying the & operator.
fn bitand(self, rhs: &'a u2) -> Self::Output[src]
Performs the & operation.
impl<'a> BitAnd<u2> for &'a u2[src]
type Output = <u2 as BitOr<u2>>::Output
The resulting type after applying the & operator.
fn bitand(self, rhs: u2) -> Self::Output[src]
Performs the & operation.
impl<'a> BitAnd<&'a u2> for &'a u2[src]
type Output = <u2 as BitOr<u2>>::Output
The resulting type after applying the & operator.
fn bitand(self, rhs: &'a u2) -> Self::Output[src]
Performs the & operation.
impl BitAndAssign<u2> for u2[src]
fn bitand_assign(&mut self, other: u2)[src]
Performs the &= operation.
impl Add<u2> for u2[src]
type Output = u2
The resulting type after applying the + operator.
fn add(self, other: u2) -> u2[src]
Performs the + operation.