first steps of making 'opt' a first class type for Nim

This commit is contained in:
Andreas Rumpf 2017-09-25 13:19:36 +02:00
commit f7f3a25be8
20 changed files with 198 additions and 35 deletions

View file

@ -246,6 +246,9 @@ type
UncheckedArray* {.unchecked.}[T] = array[0, T]
## Array with no bounds checking
when defined(nimHasOpt):
type opt*{.magic: "Opt".}[T]
proc high*[T: Ordinal](x: T): T {.magic: "High", noSideEffect.}
## returns the highest possible index of an array, a sequence, a string or
## the highest possible value of an ordinal value `x`. As a special