| Crates.io | bint |
| lib.rs | bint |
| version | 0.1.15 |
| created_at | 2019-01-20 05:06:28.497467+00 |
| updated_at | 2025-11-29 01:35:03.805479+00 |
| description | Bounded Integer in Rust. |
| homepage | https://github.com/electronicpanopticon/bint-rs |
| repository | https://github.com/electronicpanopticon/bint-rs.git |
| max_upload_size | |
| id | 109616 |
| size | 26,800 |
Bounded Integer in Rust
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());