3 ms·
"Rust is not a language that has user-definable refinement types, but you can find some examples of refinements in the standard library, like NonZero and NonNul
by weinzierl 2y ago
"Rust is not a language that has user-definable refinement types, but you can find some examples of refinements in the standard library, like NonZero and NonNull"
Rust does not have refinement types but Pattern Types are behind a feature flag and will hopefully come soon. Pattern Types are not quite refinement types but they will allow you to define NonZero et al yourself.
- psd1 2y agoI guess F#'s active patterns are refinement types. It's not clear to me whether they are types, but they are used like types, i.e. "that which matches the specified pattern"
- ratmice 2y agoThis is great, I can't wait to be able to use a NonMax type in place of NonZero in a couple of places.