| Crates.io | exint |
| lib.rs | exint |
| version | 0.1.2 |
| created_at | 2025-11-09 07:32:45.252617+00 |
| updated_at | 2025-12-11 16:46:36.584325+00 |
| description | An implementation of generic signed and unsigned integers. |
| homepage | https://github.com/l1h3r/exint |
| repository | https://github.com/l1h3r/exint |
| max_upload_size | |
| id | 1923775 |
| size | 1,140,860 |
A pure Rust implementation of generic signed and unsigned integers.
This crate provides the no_std-compatible types int<N> and uint<N>, which mimic the behavior and API of the core integer primitives while supporting fixed-width values of arbitrary precision.
[dependencies]
exint = "0.1.0"
use exint::primitive::u24;
fn main() {
let a: u24 = u24::from(123_u16);
let b: u24 = u24::from(456_u16);
let c: u24 = u24::from(10_u16);
println!("d = {}", a + b);
println!("e = {}", a.wrapping_sub(b));
println!("f = {}", u24::MAX - (c >> 1_u32));
}
Since there is no way to define your own literal format in Rust, exint provides a simple procedural macro.
The above example can be re-written as the following:
use exint::primitive::u24;
fn main() {
exint::uint! {
let a: u24 = 123_u24;
let b: u24 = 456_u24;
let c: u24 = 10_u24;
println!("d = {}", a + b);
println!("e = {}", a.wrapping_sub(b));
println!("f = {}", u24::MAX - (c >> 1_u32));
}
}
Use the exint::uint_strict! macro to avoid converting the core integer types.
use exint::uint;
fn main() {
exint::uint! {
let a: uint<3> = 123_u24; // <-- Converted
let b: uint<4> = 456_u32; // <-- Converted
}
exint::uint_strict! {
let a: uint<3> = 123_u24; // <-- Converted
let b: u32 = 456_u32; // <-- Not converted
}
}
This crate is not intended for cryptographic use. Consider using crypto-bigint if you need an integer type suitable for cryptographic applications.
| Group | Name | Nightly |
|---|---|---|
std |
no | |
all_unstable |
||
exact_bitshifts |
no | |
int_from_ascii |
no | |
int_lowest_highest_one |
no | |
int_roundings |
no | |
is_ascii_octdigit |
no | |
isolate_most_least_significant_one |
no | |
uint_bit_width |
no | |
utf16_extra |
no | |
wrapping_next_power_of_two |
no | |
all_nightly |
||
adt_const_params |
yes | |
ascii_char |
yes | |
bigint_helper_methods |
yes | |
disjoint_bitor |
yes | |
exact_div |
yes | |
f16 |
yes | |
f128 |
yes | |
funnel_shifts |
yes | |
integer_atomics |
yes | |
never_type |
yes | |
random |
yes | |
step_trait |
yes | |
structural_match |
yes | |
trusted_step |
yes | |
unsized_const_params |
yes | |
all_const |
||
const_traits |
yes | |
const_clone |
yes | |
const_cmp |
yes | |
const_convert |
yes | |
const_default |
yes | |
const_ops |
yes | |
const_option |
yes | |
const_result |
yes | |
all_backend |
||
core_intrinsics |
yes | |
const_eval_select |
yes | |
min_specialization |
yes | |
portable_simd |
yes | |
proc_macro_diagnostic |
yes |