Esc

Overflow

enumextensionsince 0.36.1Source
  • macOS: Overflow works on macOS
  • Linux: Overflow works on Linux
  • Windows: Overflow works on Windows
  • Wasm: Overflow works on Wasm

Declaration

Overflow :: enum u8 {
    CONSTRAIN;    REJECT;}

Month-end handling; e.g. January 31 plus one month constrains to February's last day.

Example↗
clamped, _ := add(Date.{ 2024, 1, 31 }, Span.{ months = 1 }, .CONSTRAIN);
assert(clamped.day == 29);
_, rejected := add(Date.{ 2024, 1, 31 }, Span.{ months = 1 }, .REJECT);
assert(rejected.kind != .NONE);

See also