Crate awint_internals

Source
Expand description

This crate contains common developer utilities for crates within the awint system, such as macros that needed a separate crate because #[macro_export] unconditionally causes macros to be publicly accessible. In rare circumstances, someone might want to use the items here for new storage types or highly optimized routines, but most users should never have to interact with this. Be aware that safety requirements can change over time, check bits.rs under awint_core.

There is a hidden reexport of this crate for awint_core, awint_ext, and awint.

Modules§

awi
Subset of awint::awi

Macros§

const_for
A basic for loop for const contexts
forward_debug_fmt
location
Returns the Location at the first layer of macros this is in
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.
unsafe_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.
unsafe_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.
unsafe_for_each
f(x) is run on every digit from first to last.
unsafe_for_each_mut
f(x) is run on every digit from first to last.

Structs§

CustomDst
A hack that is very close to the ideal of having a (NonNull<T>, NonZeroUsize) custom DST for Bits to use.
Location
Location for an item in the source code. This is essentially a std::panic::Location<'static> with all public fields.
RawBits
RawStackBits

Enums§

SerdeError
A serialization or deserialization error

Constants§

BITS
Bitwidth of a Digit
DIGIT_BYTES
Number of bytes in a Digit
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 a Digit
USIZE_BITS
Number of bits in a usize

Functions§

bits_upper_bound
Calculates the maximum bitwidth needed for a string respresentation in a given radix.
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
Returns the number of whole digits (not including a digit with unused bits) given w
digits_u
Returns the number of whole digits (not including a digit with unused bits) given w
extra
Returns the number of extra bits given w
extra_u
Returns the number of extra bits given w
panicking_bits_upper_bound
The same as bits_upper_bound except it panics internally in case of overflow
panicking_chars_upper_bound
The same as chars_upper_bound except it panics internally in case of overflow
total_digits
Returns the number of Digits needed to represent w, including any digit with unused bits
u256_div_rem
Computes the quotient and remainder of duo divided by div and returns them as a tuple.
widen_add
Computes x + y + z and returns the widened result as a tuple.
widen_mul_add
Computes (x * y) + z.
widening_mul_add_u128

Type Aliases§

Digit
The basic element of the internal slice in Bits.
IDigit
Signed version of Digit