bounded-integer
bounded-integer copied to clipboard
Bounded integers for Rust
Like the title says, allowing for explicit naming and values. For explicit naming it has some drawbacks as to doing it the old and easy way: ```rust bounded_integer! { #[repr(u8)]...
My use case of this crate is as follow: ```rust bounded_integer! { #[repr(libc::c_int)] pub struct TimeOut { -1..=libc::c_int::MAX } } bounded_integer! { #[repr(usize)] pub struct MaxEvents{ 1..=libc::c_int::MAX as usize }...
Would that be possible? As far as I understand, [only the blanket implementation is available](https://docs.rs/bounded-integer/latest/bounded_integer/examples/struct.BoundedStruct.html#impl-TryFrom%3CU%3E-for-BoundedStruct)?
```rust bounded_integer! { pub struct Test { 0..1 } } ``` This raises the following error. ```rust error: The start of the range must be before the end --> src/main.rs:10:23...
I'd like to be able to choose between new and new_saturating for the implementation of deserialize, how could this be implemented?
Our macros sometimes fail in rust-analyzer because of https://github.com/rust-lang/rust-analyzer/issues/18211. It would be good to implement more workarounds for this, i.e. ignoring None-grouped tokens.
TL;DR: It would be nice if the types created by `bounded_integer!` implemented a `BoundedInteger` trait to allow some generic reflection on the bounds. --- Hi there! Some background: I'm working...