Kestrer / bounded-integer

Bounded integers for Rust
24 stars 8 forks source link

Support for integers bound to a single value #23

Open BenjaminLucier opened 5 months ago

BenjaminLucier commented 5 months ago
bounded_integer! {
    pub struct Test { 0..1 }
}

This raises the following error.

error: The start of the range must be before the end
  --> src/main.rs:10:23
   |
10 |     pub struct Test { 0..1 }
   |                       ^^^^

Perhaps it is not a common use case but creating a bounded integer that is bound to a single value should be plausible? Based on the error message I suspect this is an off by one error in the range validation logic. New to rust, especially macros, but I'll take a look and see if I can make a PR.

BenjaminLucier commented 5 months ago

https://github.com/Kestrer/bounded-integer/pull/24