23 releases

Uses new Rust 2021

0.9.3 Feb 4, 2022
0.9.1 Jun 30, 2021
0.9.0 Jan 5, 2021
0.8.5 Aug 12, 2020
0.1.0 Dec 29, 2017

#73 in Data structures

Download history 71404/week @ 2022-02-04 53801/week @ 2022-02-11 54475/week @ 2022-02-18 59401/week @ 2022-02-25 60477/week @ 2022-03-04 61039/week @ 2022-03-11 75169/week @ 2022-03-18 69898/week @ 2022-03-25 77617/week @ 2022-04-01 71945/week @ 2022-04-08 65271/week @ 2022-04-15 67331/week @ 2022-04-22 62171/week @ 2022-04-29 64263/week @ 2022-05-06 61757/week @ 2022-05-13 63022/week @ 2022-05-20

264,084 downloads per month
Used in 864 crates (73 directly)

MIT/Apache

52KB
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

~210KB