Crate awint_internals[][src]

Expand description

This crate contains common utilities for crates within the awint system. Some of these are highly unsafe macros that were only placed here because #[macro_export] unconditionally causes macros to be publicly accessible. To prevent them from being accessible from intended user-facing crates, this _internals crate was made. The safety requirements of these macros may change over time, so this crate should never be used outside of this system.

Macros

binop_for_each

If lhs.bw() != rhs.bw(), this returns None, otherwise f(x, y) is run on every corresponding pair of digits from first to last.

binop_for_each_mut

If lhs.bw() != rhs.bw(), this returns None, otherwise f(x, y) is run on every corresponding pair of digits from first to last.

const_for

A basic for loop for const contexts

for_each

f(x) is run on every digit from first to last.

for_each_mut

f(x) is run on every digit from first to last.

subdigits_mut

Runs f on a digitwise subslice subbits of bits. This is a macro because closures are not properly supported in const functions yet.

Enums

SerdeError

A serialization or deserialization error

Constants

BITS

Maximum bitwidth of an inline Awi

INV_LB_I1F15

Reciprocal binary logarithms of the numbers 2..=36 rounded up and in u16p15 fixed point format

LB_I3F13

Binary logarithms of the integers 2..=36 rounded up and in u16p13 fixed point format

MAX

Maximum value of an inline Awi

Functions

bits_upper_bound

This is used for quickly calculating the maximum number of bits needed for a string representation of a number in some radix to be represented. This may give more bits than needed, but is guaranteed to never underestimate the number of bits needed. Returns None if we see memory exhaustion

bw

Utility free function for converting a usize to a NonZeroUsize. This is mainly intended for usage with literals, and shouldn’t be used for fallible conversions.

chars_upper_bound

This takes an input of significant bits and gives an upper bound for the number of characters in the given radix needed to represent those bits.

dd_division

Divides duo by div and returns the quotient and remainder.

digits
extra
regular_digits
widen_add

Computes x + y + z and returns the widened result as a tuple.

widen_mul_add

Computes (x * y) + z. This cannot overflow, because it returns the value widened into a tuple, where the first element is the least significant part of the integer and the second is the most significant.