This commit is contained in:
Araq 2014-08-31 01:07:58 +02:00
commit 09ab1703e1
6 changed files with 30 additions and 13 deletions

View file

@ -874,13 +874,13 @@ proc contains*[T](s: Slice[T], value: T): bool {.noSideEffect, inline.} =
## assert((1..3).contains(4) == false)
result = s.a <= value and value <= s.b
template `in` * (x, y: expr): expr {.immediate.} = contains(y, x)
template `in` * (x, y: expr): expr {.immediate, dirty.} = contains(y, x)
## Sugar for contains
##
## .. code-block:: Nim
## assert(1 in (1..3) == true)
## assert(5 in (1..3) == false)
template `notin` * (x, y: expr): expr {.immediate.} = not contains(y, x)
template `notin` * (x, y: expr): expr {.immediate, dirty.} = not contains(y, x)
## Sugar for not containing
##
## .. code-block:: Nim