move toDeque to after addLast (#19233) [backport:1.0]

Changes the order of procs definitions in order to avoid calling an undefined proc.

(cherry picked from commit c989542339)
This commit is contained in:
MichalMarsalek
2021-12-10 07:39:12 +01:00
committed by narimiran
parent ac57c3193d
commit 83c472c40d

View File

@@ -87,20 +87,6 @@ proc initDeque*[T](initialSize: int = defaultInitialSize): Deque[T] =
## * `toDeque proc <#toDeque,openArray[T]>`_
result.initImpl(initialSize)
proc toDeque*[T](x: openArray[T]): Deque[T] {.since: (1, 3).} =
## Creates a new deque that contains the elements of `x` (in the same order).
##
## **See also:**
## * `initDeque proc <#initDeque,int>`_
runnableExamples:
let a = toDeque([7, 8, 9])
assert len(a) == 3
assert $a == "[7, 8, 9]"
result.initImpl(x.len)
for item in items(x):
result.addLast(item)
proc len*[T](deq: Deque[T]): int {.inline.} =
## Returns the number of elements of `deq`.
result = deq.count
@@ -303,6 +289,20 @@ proc addLast*[T](deq: var Deque[T], item: sink T) =
deq.data[deq.tail] = item
deq.tail = (deq.tail + 1) and deq.mask
proc toDeque*[T](x: openArray[T]): Deque[T] {.since: (1, 3).} =
## Creates a new deque that contains the elements of `x` (in the same order).
##
## **See also:**
## * `initDeque proc <#initDeque,int>`_
runnableExamples:
let a = toDeque([7, 8, 9])
assert len(a) == 3
assert $a == "[7, 8, 9]"
result.initImpl(x.len)
for item in items(x):
result.addLast(item)
proc peekFirst*[T](deq: Deque[T]): lent T {.inline.} =
## Returns the first element of `deq`, but does not remove it from the deque.
##