| Crates.io | awint_core |
| lib.rs | awint_core |
| version | 0.18.1 |
| created_at | 2021-05-22 02:34:26.649264+00 |
| updated_at | 2025-03-15 21:33:02.026006+00 |
| description | Core no-std and no-alloc `awint` functionality |
| homepage | |
| repository | https://github.com/AaronKutch/awint |
| max_upload_size | |
| id | 400689 |
| size | 241,402 |
This system of crates together forms a kind of big-integer library with separated storage and
functional structs, manually controlled bitwidth, and bitwidth dependent operations. Instead of one
struct that has all of the allocation and functional capabilities, there are 3 storage types which
manage allocation: InlAwi, ExtAwi, and Awi. There is a common Bits reference type that
manages fixed width arithmetical functionality. Most operations on Bits are const and have no
allocations. Bits backed by InlAwi can perform big-integer arithmetic both at compile time and
in a no-std runtime without any allocator at all. Bits backed by ExtAwi can use dynamic
bitwidths at runtime. Awi has capacity and cheap bitwidth resizing. If a function is written
purely in terms of Bits, then any mix of InlAwis, ExtAwis, and Awis can be used as arguments
to that function with the help of their Deref<Target = Bits> impls.
A generic FP struct for fixed point numbers is also included, adding more functions for it is
currently a WIP. In the future, Awi should also be able to have automatic resizing functions like
in traditional bigint libraries.
Bits and InlAwi are provided by the awint_core crate. ExtAwi, Awi, and FP are provided
by the awint_ext crate. The reason for this split is to provide maximum flexibility to no-std
and no-alloc use cases. ExtAwi is not within awint_core under a feature flag, because if a
no-alloc project depended on both awint_core and awint_macros (which requires ExtAwi), the
flag would be activated for the common compilation of awint_core.
The awint_macros crate is a proc-macro crate with several construction utilities.
The awint_dag crate supplies a way to use awint types as a DSL (Domain Specific Language) for
combinational logic.
The awint crate compiles these interfaces together and enables or disables different parts of the
system depending on these feature flags:
constawint_dagdag::Option and dag::Result to fully workrand_core without its default featuresserde without its default featureszeroize without its default featuresNote: By default, "std" and "try_support" is turned on, use default-features = false and select
specific features to be more specific.
NOTE: As of Rust 1.70, if you try to use "const_support" with the macros you may get strange "erroneous constant used" and "deref_mut" errors unless you add all of
#![feature(const_trait_impl)]
#![feature(const_mut_refs)]
#![feature(const_option)]
to all of the crate roots where you use the macros in const contexts.
NOTE: As of some versions of Rust starting around 1.70, "const_support" is unfortunately broken on nightly (see https://github.com/AaronKutch/awint/issues/19).
These are currently unimplemented because of other developments and improvements that are being prioritized. Please open an issue or PR if you would like these implemented faster.
x.add_(y) would have the
alternative z = x.add(y) or z = x + y) and the macro optimizes storage creation and routing.awint_dagawint_dagFPAwiconst Karatsuba algorithm to multiplication if possible, or add a fast_mul function to
awint_extExtAwiconst feature, and will hopefully be stabilized soon.