[]Struct lv2rs::prelude::u4

pub struct u4(_);

The 4-bit unsigned integer type.

Methods

impl u4

pub const MAX: u4

pub const MIN: u4

impl u4

pub fn min_value() -> u4

Returns the smallest value that can be represented by this integer type.

pub fn max_value() -> u4

Returns the largest value that can be represented by this integer type.

pub fn new(value: u8) -> u4

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: u4) -> u4

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: u4) -> u4

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 Copy for u4

impl Ord for u4

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl Clone for u4

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a> BitAnd<&'a u4> for u4

type Output = <u4 as BitOr<u4>>::Output

The resulting type after applying the & operator.

impl<'a> BitAnd<&'a u4> for &'a u4

type Output = <u4 as BitOr<u4>>::Output

The resulting type after applying the & operator.

impl<'a> BitAnd<u4> for &'a u4

type Output = <u4 as BitOr<u4>>::Output

The resulting type after applying the & operator.

impl BitAnd<u4> for u4

type Output = u4

The resulting type after applying the & operator.

impl BitOrAssign<u4> for u4

impl<T> ShrAssign<T> for u4 where
    u8: ShrAssign<T>, 

impl BitAndAssign<u4> for u4

impl Binary for u4

impl Hash for u4

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

Feeds a slice of this type into the given [Hasher]. Read more

impl Add<u4> for u4

type Output = u4

The resulting type after applying the + operator.

impl UpperHex for u4

impl<'a> BitOr<u4> for &'a u4

type Output = <u4 as BitOr<u4>>::Output

The resulting type after applying the | operator.

impl<'a> BitOr<&'a u4> for &'a u4

type Output = <u4 as BitOr<u4>>::Output

The resulting type after applying the | operator.

impl<'a> BitOr<&'a u4> for u4

type Output = <u4 as BitOr<u4>>::Output

The resulting type after applying the | operator.

impl BitOr<u4> for u4

type Output = u4

The resulting type after applying the | operator.

impl From<u2> for u4

impl From<u4> for u14

impl From<u4> for u7

impl From<u3> for u4

impl PartialOrd<u4> for u4

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Eq for u4

impl Debug for u4

impl Sub<u4> for u4

type Output = u4

The resulting type after applying the - operator.

impl<'a> BitXor<&'a u4> for u4

type Output = <u4 as BitOr<u4>>::Output

The resulting type after applying the ^ operator.

impl BitXor<u4> for u4

type Output = u4

The resulting type after applying the ^ operator.

impl<'a> BitXor<u4> for &'a u4

type Output = <u4 as BitOr<u4>>::Output

The resulting type after applying the ^ operator.

impl<'a> BitXor<&'a u4> for &'a u4

type Output = <u4 as BitOr<u4>>::Output

The resulting type after applying the ^ operator.

impl Default for u4

impl<T> Shr<T> for u4 where
    u8: Shr<T>,
    <u8 as Shr<T>>::Output == u8

type Output = u4

The resulting type after applying the >> operator.

impl Octal for u4

impl PartialEq<u4> for u4

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl<T> ShlAssign<T> for u4 where
    u8: ShlAssign<T>, 

impl<'a> Not for &'a u4

type Output = <u4 as Not>::Output

The resulting type after applying the ! operator.

impl Not for u4

type Output = u4

The resulting type after applying the ! operator.

impl<T> Shl<T> for u4 where
    u8: Shl<T>,
    <u8 as Shl<T>>::Output == u8

type Output = u4

The resulting type after applying the << operator.

impl Display for u4

impl BitXorAssign<u4> for u4

impl LowerHex for u4

Auto Trait Implementations

impl Send for u4

impl Sync for u4

Blanket Implementations

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> From for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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