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 subslicesubbits
ofbits
. This is a macro because closures are not properly supported inconst
functions yet. - unsafe_
binop_ for_ each - If
lhs.bw() != rhs.bw()
, this returnsNone
, otherwisef(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 returnsNone
, otherwisef(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§
- Custom
Dst - A hack that is very close to the ideal of having a
(NonNull<T>, NonZeroUsize)
custom DST forBits
to use. - Location
- Location for an item in the source code. This is essentially a
std::panic::Location<'static>
with all public fields. - RawBits
- RawStack
Bits
Enums§
- Serde
Error - 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 aNonZeroUsize
. 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
bydiv
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
Digit
s needed to representw
, including any digit with unused bits - u256_
div_ rem - Computes the quotient and remainder of
duo
divided bydiv
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