From d49a57f9436db2f53ae41457778a93d4543589f9 Mon Sep 17 00:00:00 2001 From: Eugene Kabanov Date: Mon, 27 Aug 2018 17:37:39 +0300 Subject: [PATCH] Fix MutRange[T] problems. (#26) --- ranges/typedranges.nim | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ranges/typedranges.nim b/ranges/typedranges.nim index 7e109ac..f16537e 100644 --- a/ranges/typedranges.nim +++ b/ranges/typedranges.nim @@ -211,24 +211,23 @@ template advanceImpl(a, b: untyped): bool = proc tryAdvance*[T](x: var Range[T], idx: int): bool = ## Move internal start offset of range ``x`` by ``idx`` elements forward. - ## + ## ## 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) -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. - ## + ## ## Returns ``true`` if operation got completed successfully, or - ## ``false`` if you are trying to overrun range ``x``. - result = x.advanceImpl(idx) + ## ``false`` if you are trying to overrun range ``x``. + result = tryAdvance(Range[T](x), idx) proc advance*[T](x: var Range[T], idx: int) = ## Move internal start offset of range ``x`` by ``idx`` elements forward. let res = x.advanceImpl(idx) 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. - let res = x.advanceImpl(idx) - if not res: raise newException(IndexError, "Advance Error") + advance(Range[T](x), idx)