Struct awint_core::InlAwi[][src]

pub struct InlAwi<const BW: usize, const LEN: usize> { /* fields omitted */ }
Expand description

An arbitrary width integer with const generic bitwidth that can be stored inline on the stack like an array.

NOTE: Ideally, you could just type let _: InlAwi<100> = InlAwi<100>::zero(); if you wanted to specify and construct an InlAwi type with bitwidth 100. However, Rust’s lack of custom DST support and const generics limitations makes this currently impossible. The two const generic parameters of an InlAwi are part of a workaround for this. Typing out a let _: InlAwi<BW, LEN> = InlAwi<BW, LEN>::unstable_zero() should not be done directly because it is non-portable and relies on unstable internal details. Instead, you should use let _: inlawi_ty!(100) = inlawi_zero!(100); using macros from the awint_macros crate.

Implementations

impl<'a, const BW: usize, const LEN: usize> InlAwi<BW, LEN>[src]

pub const fn const_as_ref(&'a self) -> &'a Bits[src]

Returns a reference to self in the form of &Bits.

pub const fn const_as_mut(&'a mut self) -> &'a mut Bits[src]

Returns a reference to self in the form of &mut Bits.

pub const fn nzbw(&self) -> NonZeroUsize[src]

Returns the bitwidth of this InlAwi as a NonZeroUsize

pub const fn bw(&self) -> usize[src]

Returns the bitwidth of this InlAwi as a usize

pub const fn len(&self) -> usize[src]

Returns the exact number of usize digits needed to store all bits.

Trait Implementations

impl<const BW: usize, const LEN: usize> Binary for InlAwi<BW, LEN>[src]

Forwards to the corresponding impl for Bits

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

Formats the value using the given formatter.

impl<const BW: usize, const LEN: usize> Clone for InlAwi<BW, LEN>[src]

fn clone(&self) -> InlAwi<BW, LEN>[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<const BW: usize, const LEN: usize> Debug for InlAwi<BW, LEN>[src]

Forwards to the corresponding impl for Bits

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

Formats the value using the given formatter. Read more

impl<const BW: usize, const LEN: usize> Hash for InlAwi<BW, LEN>[src]

fn hash<H: Hasher>(&self, state: &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]

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

impl<const BW: usize, const LEN: usize> LowerHex for InlAwi<BW, LEN>[src]

Forwards to the corresponding impl for Bits

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

Formats the value using the given formatter.

impl<const BW: usize, const LEN: usize> Octal for InlAwi<BW, LEN>[src]

Forwards to the corresponding impl for Bits

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

Formats the value using the given formatter.

impl<const BW: usize, const LEN: usize> PartialEq<InlAwi<BW, LEN>> for InlAwi<BW, LEN>[src]

If self and other have unmatching bit widths, false will be returned.

fn eq(&self, rhs: &Self) -> bool[src]

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

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

This method tests for !=.

impl<const BW: usize, const LEN: usize> UpperHex for InlAwi<BW, LEN>[src]

Forwards to the corresponding impl for Bits

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

Formats the value using the given formatter.

impl<const BW: usize, const LEN: usize> Copy for InlAwi<BW, LEN>[src]

impl<const BW: usize, const LEN: usize> Eq for InlAwi<BW, LEN>[src]

If self and other have unmatching bit widths, false will be returned.

impl<const BW: usize, const LEN: usize> Send for InlAwi<BW, LEN>[src]

InlAwi is safe to send between threads since it does not own aliasing memory and has no reference counting mechanism like Rc.

impl<const BW: usize, const LEN: usize> Sync for InlAwi<BW, LEN>[src]

InlAwi is safe to share between threads since it does not own aliasing memory and has no mutable internal state like Cell or RefCell.

Auto Trait Implementations

impl<const BW: usize, const LEN: usize> Unpin for InlAwi<BW, LEN>

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

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

Performs the conversion.

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.

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

Performs the conversion.