26 releases

0.10.0 Sep 11, 2024
0.9.5 Nov 29, 2022
0.9.4 Sep 20, 2022
0.9.3 Feb 4, 2022
0.1.0 Dec 29, 2017

#22 in Algorithms

Download history 231227/week @ 2024-10-30 224859/week @ 2024-11-06 217378/week @ 2024-11-13 216052/week @ 2024-11-20 225366/week @ 2024-11-27 253147/week @ 2024-12-04 233758/week @ 2024-12-11 179757/week @ 2024-12-18 103336/week @ 2024-12-25 173798/week @ 2025-01-01 239573/week @ 2025-01-08 268062/week @ 2025-01-15 262281/week @ 2025-01-22 274195/week @ 2025-01-29 309206/week @ 2025-02-05 251018/week @ 2025-02-12

1,140,144 downloads per month
Used in 3,081 crates (144 directly)

MIT/Apache

53KB
1.5K SLoC

Uint

Description

Provides facilities to construct big unsigned integer types which use no allocations (stack-based, fixed bit length). If you want to use a predefined U128, U256 or U512 type, take a look at the primitive-types or ethereum-types crate.

The focus on the provided big unsigned integer types is performance and cross-platform availability. Support a very similar API as the built-in primitive integer types.

Usage

In your Cargo.toml paste

uint = "0.8"

Import the macro

use uint::construct_uint;

If you're using pre-edition Rust in your main file

#[macro_use]
extern crate uint;

Construct your own big unsigned integer type as follows.

// U1024 with 1024 bits consisting of 16 x 64-bit words
construct_uint! {
	pub struct U1024(16);
}

Tests

Basic tests

cargo test --release

Basic tests + property tests

cargo test --release --features=quickcheck

Benchmark tests

cargo bench

Fuzz tests

see fuzz README.md

Crate Features

  • std: Use Rust's standard library.
    • Enables byteorder/std, rustc-hex/std
    • Enabled by default.
  • quickcheck: Enable quickcheck-style property testing
    • Use with cargo test --release --features=quickcheck.
  • arbitrary: Allow for creation of an uint object from random unstructured input for use with fuzzers that use the arbitrary crate.
    • Disabled by default.

Dependencies

~150–410KB