News for hackers. Stuff that matters.
Re:What would it take to add refinement types to Rust? by archargelod on Tuesday December 24, 2024 @10:24PM (#42506625)
Nim has Natural and Positive (signed int) types that checked at compile and runtime. You can also define arbitrary range types for any ordinal type, for example enums:

  type
    Month = enum Jan, Feb, Mar, Apr, May, ...
    SpringMonth = range[Mar..May]
  
  var m: SpringMonth = Mar
It will raise under/overflow exception if value falls out of range.

There are no comments on this comment yet.