| ▲ | fpoling 5 hours ago | |||||||||||||||||||||||||
Arbitrary subranges of int types were available in Ada for over 40 years via static enforcement via Spark and compilers were able to optimize them nicely. For a system language I wish Rust would support such things rather than coming with NonZero hacks. | ||||||||||||||||||||||||||
| ▲ | steveklabnik 4 hours ago | parent | next [-] | |||||||||||||||||||||||||
This is called "pattern types" in Rust land, as your parent mentioned, and is exactly the kind of work being talked about. NonZero isn't a hack: it's an example of a common pattern. If pattern types were available today, you'd still want NonZero, as an example of a pretty standard pattern. The idea is, as always: prove out the specific version, then generalize. | ||||||||||||||||||||||||||
| ▲ | BoingBoomTschak 3 hours ago | parent | prev [-] | |||||||||||||||||||||||||
Can it do holes like this? | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||