Fix MutRange[T] problems. (#26)

This commit is contained in:
Eugene Kabanov 2018-08-27 17:37:39 +03:00 committed by Yuriy Glukhov
parent 49f32c604b
commit d49a57f943
1 changed files with 8 additions and 9 deletions

View File

@ -216,19 +216,18 @@ proc tryAdvance*[T](x: var Range[T], idx: int): bool =
## ``false`` if you are trying to overrun range ``x``. ## ``false`` if you are trying to overrun range ``x``.
result = x.advanceImpl(idx) result = x.advanceImpl(idx)
proc tryAdvance*[T](x: var MutRange[T], idx: int): bool = proc tryAdvance*[T](x: var MutRange[T], idx: int): bool {.inline.} =
## Move internal start offset of range ``x`` by ``idx`` elements forward. ## Move internal start offset of range ``x`` by ``idx`` elements forward.
## ##
## Returns ``true`` if operation got completed successfully, or ## Returns ``true`` if operation got completed successfully, or
## ``false`` if you are trying to overrun range ``x``. ## ``false`` if you are trying to overrun range ``x``.
result = x.advanceImpl(idx) result = tryAdvance(Range[T](x), idx)
proc advance*[T](x: var Range[T], idx: int) = proc advance*[T](x: var Range[T], idx: int) =
## Move internal start offset of range ``x`` by ``idx`` elements forward. ## Move internal start offset of range ``x`` by ``idx`` elements forward.
let res = x.advanceImpl(idx) let res = x.advanceImpl(idx)
if not res: raise newException(IndexError, "Advance Error") if not res: raise newException(IndexError, "Advance Error")
proc advance*[T](x: var MutRange[T], idx: int) = proc advance*[T](x: var MutRange[T], idx: int) {.inline.} =
## Move internal start offset of range ``x`` by ``idx`` elements forward. ## Move internal start offset of range ``x`` by ``idx`` elements forward.
let res = x.advanceImpl(idx) advance(Range[T](x), idx)
if not res: raise newException(IndexError, "Advance Error")