3 ms·
Eventually it will be possible to write new types like this in stable Rust, the current approach is Pattern Types. Today you can do this in nightly Rust, using
by tialaramex 4y ago
Eventually it will be possible to write new types like this in stable Rust, the current approach is Pattern Types.
Today you can do this in nightly Rust, using a deliberately permanently unstable attribute, that's what my nook crate does to produce e.g. BalancedI8 which is a signed byte from -127 to 127. It will be nice when some day Pattern Types, or an equivalent are stabilized.