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§

  • Subset of awint::awi

Macros§

  • A basic for loop for const contexts
  • Returns the Location at the first layer of macros this is in
  • Runs f on a digitwise subslice subbits of bits. This is a macro because closures are not properly supported in const functions yet.
  • If lhs.bw() != rhs.bw(), this returns None, otherwise f(x, y) is run on every corresponding pair of digits from first to last.
  • If lhs.bw() != rhs.bw(), this returns None, otherwise f(x, y) is run on every corresponding pair of digits from first to last.
  • f(x) is run on every digit from first to last.
  • f(x) is run on every digit from first to last.

Structs§

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

Enums§

  • A serialization or deserialization error

Constants§

  • Bitwidth of a Digit
  • Number of bytes in a Digit
  • Reciprocal binary logarithms of the numbers 2..=36 rounded up and in u16p15 fixed point format
  • Binary logarithms of the integers 2..=36 rounded up and in u16p13 fixed point format
  • Maximum value of a Digit
  • Number of bits in a usize

Functions§

  • 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
  • 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.
  • 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.
  • Divides duo by div and returns the quotient and remainder.
  • Returns the number of whole digits (not including a digit with unused bits) given w
  • Returns the number of whole digits (not including a digit with unused bits) given w
  • Returns the number of extra bits given w
  • Returns the number of extra bits given w
  • The same as bits_upper_bound except it panics internally in case of overflow
  • The same as chars_upper_bound except it panics internally in case of overflow
  • Returns the number of Digits needed to represent w, including any digit with unused bits
  • Computes x + y + z and returns the widened result as a tuple.
  • 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.

Type Aliases§

  • The basic element of the internal slice in Bits. This should be a type alias of the unsigned integer of the architecture’s registers. On most architectures, this is simply usize, however there are cases such as AVR where the pointer size is 16 bits but the register size is 8 bits. If this were not register size, it can incur excessive unrolling or underutilization for every loop in the internals.
  • Signed version of Digit