summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichalMarsalek <MichalMarsalek@users.noreply.github.com>2021-12-10 07:39:12 +0100
committerGitHub <noreply@github.com>2021-12-10 07:39:12 +0100
commitc98954233981cb30807bd8be8b805663d44964d1 (patch)
tree4f5ed96907aa8d1bb226670fb0135de743c52d9f
parentd39147219a41f54b45b585a103bfb04cce71c52c (diff)
downloadNim-c98954233981cb30807bd8be8b805663d44964d1.tar.gz
move toDeque to after addLast (#19233) [backport:1.0]
Changes the order of procs definitions in order to avoid calling an undefined proc.
-rw-r--r--lib/pure/collections/deques.nim28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/pure/collections/deques.nim b/lib/pure/collections/deques.nim
index ecdf199d2..c4eb5331e 100644
--- a/lib/pure/collections/deques.nim
+++ b/lib/pure/collections/deques.nim
@@ -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.
   ##