bounded-integer icon indicating copy to clipboard operation
bounded-integer copied to clipboard

Support for integers bound to a single value

Open BenjaminLucier opened this issue 1 year ago • 1 comments

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 avatar May 02 '24 04:05 BenjaminLucier

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

BenjaminLucier avatar May 02 '24 04:05 BenjaminLucier

I believe this should be supported in 0.6.0 anyway.

Kestrer avatar Aug 08 '25 18:08 Kestrer