Type Alias hazardflow_designs::std::value::U

source ·
pub type U<const N: usize> = Array<bool, N>;
Expand description

An unsigned integer with bitwidth N.

The lower bits of the integer are represented by the lower index of the array, and vice versa. In other words, the least significant bit of the integer is the 0th element of the array, and the most significant bit is the (N - 1)-th element.

Aliased Type§

struct U<const N: usize> { /* private fields */ }

Implementations§

source§

impl<const N: usize> U<N>

source

pub fn trunk_add(self, rhs: Self) -> Self

Adds two U<N>s and truncate the result to U<N>.

source§

impl<const N: usize> U<N>

source

pub fn unsigned_max() -> U<N>

Returns the maximum value of an N bit unsigned value. (i.e., 2^N - 1)

source§

impl<V: Copy + Default, const N: usize> Array<V, N>

source

pub fn fold_assoc<F: FnOnce(V, V) -> V>(self, f: F) -> V

Folds the array into a single value.

The fold order is not guaranteed, so the operation f must be associative.

source

pub fn find_idx(self, f: impl Fn(V) -> bool) -> HOption<U<{ _ }>>

Finds the index of the first element that satisfies the given condition.

source§

impl<V: Copy, const N: usize> Array<V, N>

source

pub fn set<Idx: Into<U<{ _ }>>>(self, _idx: Idx, _elt: V) -> Array<V, N>

Returns a new array with the idx-th element set to elt.

source

pub fn set_cond(self, cond: bool, idx: U<{ _ }>, elt: V) -> Array<V, N>

Returns a new array with the idx-th element set to elt if cond is true.

source

pub fn clip_const<const M: usize>(self, _index: usize) -> Array<V, M>

Returns a new clipped array of size M starting from index.

source

pub fn zip<W: Copy>(self, _other: Array<W, N>) -> Array<(V, W), N>

Returns a new array that has tuples from the two given arrays as elements.

source

pub fn enumerate(self) -> Array<(U<{ _ }>, V), N>

Returns a new array whose elements are enumerated with their indices.

source

pub fn map<W: Copy, F: FnOnce(V) -> W>(self, _f: F) -> Array<W, N>

Transforms elements of self using f.

source

pub fn fold<B: Copy, F: FnOnce(B, V) -> B>(self, _init: B, _f: F) -> B

Folds the array into a single value.

The fold order is from left to right. (i.e. foldl)

source

pub fn any<F: Fn(V) -> bool>(self, f: F) -> bool

Tests if any element matches a predicate.

source

pub fn all<F: Fn(V) -> bool>(self, f: F) -> bool

Tests if every element matches a predicate. TODO: Use tree fold?

source

pub fn resize<const M: usize>(self) -> Array<V, M>

Resizes the given array.

source

pub fn chunk<const M: usize>(self) -> Array<Array<V, M>, { _ }>

Chunks the array into an array of arrays.

source

pub fn append<const M: usize>(self, _other: Array<V, M>) -> Array<V, { _ }>

Returns a new array with the two given arrays appended.

source

pub fn set_range<const M: usize>( self, _index: usize, _other: Array<V, M> ) -> Array<V, N>

Returns a new array with the M elements starting from index set to the elements of other.

source

pub fn cartesian_product<W: Copy, const M: usize>( self, other: Array<W, M> ) -> Array<(V, W), { _ }>

Returns a Cartesian product of the two arrays.

source

pub fn reverse(self) -> Array<V, N>

Reverses the array.

Trait Implementations§

source§

impl<const N: usize> Add for U<N>

§

type Output = Array<bool, { N + 1 }>

The resulting type after applying the + operator.
source§

fn add(self, _rhs: U<N>) -> U<{ _ }>

Performs the + operation. Read more
source§

impl From<LocalAddr> for U<32>

source§

fn from(value: LocalAddr) -> Self

Converts to this type from the input type.
source§

impl<const N: usize> From<S<N>> for U<N>

source§

fn from(value: S<N>) -> U<N>

Converts to this type from the input type.
source§

impl From<bool> for U<1>

source§

fn from(_value: bool) -> U<1>

Converts to this type from the input type.
source§

impl<const N: usize> From<i32> for U<N>

source§

fn from(_value: i32) -> U<N>

Converts to this type from the input type.
source§

impl<const N: usize> From<u128> for U<N>

source§

fn from(_value: u128) -> U<N>

Converts to this type from the input type.
source§

impl<const N: usize> From<u32> for U<N>

source§

fn from(_value: u32) -> U<N>

Converts to this type from the input type.
source§

impl<const N: usize> From<usize> for U<N>

source§

fn from(_value: usize) -> U<N>

Converts to this type from the input type.
source§

impl<const N: usize, const M: usize> Mul<Array<bool, M>> for U<N>

§

type Output = Array<bool, { N + M }>

The resulting type after applying the * operator.
source§

fn mul(self, _other: U<M>) -> Self::Output

Performs the * operation. Read more
source§

impl<const N: usize> Not for U<N>

§

type Output = Array<bool, N>

The resulting type after applying the ! operator.
source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
source§

impl<const N: usize> PartialOrd for U<N>

source§

fn partial_cmp(&self, _other: &Self) -> Option<Ordering>

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

fn lt(&self, _other: &Self) -> bool

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

fn le(&self, _other: &Self) -> bool

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

fn gt(&self, _other: &Self) -> bool

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

fn ge(&self, _other: &Self) -> bool

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

impl<const N: usize, const M: usize> Shl<Array<bool, M>> for U<N>

§

type Output = Array<bool, N>

The resulting type after applying the << operator.
source§

fn shl(self, _lhs: U<M>) -> Self::Output

Performs the << operation. Read more
source§

impl<const N: usize> Shl<usize> for U<N>

§

type Output = Array<bool, N>

The resulting type after applying the << operator.
source§

fn shl(self, _lhs: usize) -> Self::Output

Performs the << operation. Read more
source§

impl<const N: usize, const M: usize> Shr<Array<bool, M>> for U<N>

§

type Output = Array<bool, N>

The resulting type after applying the >> operator.
source§

fn shr(self, _rhs: U<M>) -> Self::Output

Performs the >> operation. Read more
source§

impl<const N: usize> Shr<usize> for U<N>

§

type Output = Array<bool, N>

The resulting type after applying the >> operator.
source§

fn shr(self, _rhs: usize) -> Self::Output

Performs the >> operation. Read more
source§

impl<const N: usize> Sub for U<N>

§

type Output = Array<bool, N>

The resulting type after applying the - operator.
source§

fn sub(self, _other: U<N>) -> U<N>

Performs the - operation. Read more
source§

impl<V: Copy, const N: usize> BitAnd for Array<V, N>

§

type Output = Array<V, N>

The resulting type after applying the & operator.
source§

fn bitand(self, _rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl<V: Copy + Copy, const N: usize> Copy for Array<V, N>

source§

impl<V: Copy, const N: usize> From<[V; N]> for Array<V, N>

source§

fn from(_value: [V; N]) -> Self

Converts to this type from the input type.
source§

impl<V: Copy, const M: usize> Index<usize> for Array<V, M>

§

type Output = V

The returned type after indexing.
source§

fn index(&self, _idx: usize) -> &V

Performs the indexing (container[index]) operation. Read more
source§

impl<V: Copy, const N: usize, const M: usize> Index<Array<bool, N>> for Array<V, M>

§

type Output = V

The returned type after indexing.
source§

fn index(&self, _idx: U<N>) -> &V

Performs the indexing (container[index]) operation. Read more
source§

impl<V: Clone + Copy, const N: usize> Clone for Array<V, N>

source§

fn clone(&self) -> Array<V, N>

Returns a copy 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<V: Copy + Default, const N: usize> Default for Array<V, N>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<V: Copy, const N: usize> BitOr for Array<V, N>

§

type Output = Array<V, N>

The resulting type after applying the | operator.
source§

fn bitor(self, _rhs: Self) -> Self::Output

Performs the | operation. Read more
source§

impl<V: Debug + Copy, const N: usize> Debug for Array<V, N>

source§

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

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

impl<V: Copy, const N: usize> BitXor for Array<V, N>

§

type Output = Array<V, N>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, _rhs: Self) -> Self

Performs the ^ operation. Read more
source§

impl<V: Copy, const N: usize> PartialEq for Array<V, N>

source§

fn eq(&self, _other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, _other: &Self) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.