16 releases

0.1.16 Apr 9, 2026
0.1.15 Nov 29, 2025
0.1.12 Oct 13, 2025
0.1.7 Sep 28, 2025
0.1.0 Jan 20, 2019

#684 in Rust patterns

Download history 99/week @ 2026-01-15 71/week @ 2026-01-22 43/week @ 2026-01-29 66/week @ 2026-02-05 145/week @ 2026-02-12 33/week @ 2026-02-19 27/week @ 2026-02-26 110/week @ 2026-03-05 154/week @ 2026-03-12 235/week @ 2026-03-19 212/week @ 2026-03-26 104/week @ 2026-04-02 61/week @ 2026-04-09 78/week @ 2026-04-16 32/week @ 2026-04-23 47/week @ 2026-04-30

220 downloads per month
Used in pkcore

MIT license

25KB
434 lines

Build Status License: MIT Crates.io Version

bint-rs

Bounded Integer in Rust

Usage

Original immutable Bint:

use bint::Bint;

let b: bint::Bint = bint::Bint {value: 5, boundary: 6 };
let c: Bint = b.up();
let d: Bint = c.up_x(2);

assert_eq!(5, b.value);
assert_eq!(0, c.value);
assert_eq!(2, d.value);

New and improved BintCell:

use bint::BintCell;

let b = BintCell::new(6);
assert_eq!(5, b.down());

b.up();
b.up();
b.up_x(2);
assert_eq!(3, b.value());

New DrainableBintCell that expires after a certain number of usages:

use bint::DrainableBintCell;

let b = DrainableBintCell::new(4, 4);

assert_eq!(1, b.up().unwrap());
assert_eq!(2, b.up().unwrap());
assert_eq!(3, b.up().unwrap());
assert_eq!(0, b.up().unwrap());
assert!(b.up().is_none());

Other examples

No runtime deps