15 releases

0.1.15 Nov 29, 2025
0.1.14 Nov 27, 2025
0.1.12 Oct 13, 2025
0.1.7 Sep 28, 2025
0.1.0 Jan 20, 2019

#711 in Rust patterns

Download history 74/week @ 2025-10-02 752/week @ 2025-10-09 119/week @ 2025-10-16 16/week @ 2025-10-23 8/week @ 2025-10-30 1/week @ 2025-11-06 88/week @ 2025-11-27 38/week @ 2025-12-04 5/week @ 2025-12-18 104/week @ 2025-12-25 68/week @ 2026-01-01 12/week @ 2026-01-08 99/week @ 2026-01-15

287 downloads per month

MIT license

24KB
424 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