mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-08 14:03:23 +00:00
Deques compilation error fix (#5591)
This commit is contained in:
committed by
Andreas Rumpf
parent
d4b4cad4ea
commit
268a1f7cfd
@@ -80,7 +80,7 @@ proc `[]`*[T](deq: Deque[T], i: Natural) : T {.inline.} =
|
||||
## Access the i-th element of `deq` by order from first to last.
|
||||
## deq[0] is the first, deq[^1] is the last.
|
||||
xBoundsCheck(deq, i)
|
||||
return deq.data[(deq.first + i) and deq.mask]
|
||||
return deq.data[(deq.head + i) and deq.mask]
|
||||
|
||||
proc `[]`*[T](deq: var Deque[T], i: Natural): var T {.inline.} =
|
||||
## Access the i-th element of `deq` and returns a mutable
|
||||
@@ -266,4 +266,4 @@ when isMainModule:
|
||||
foo(1,1)
|
||||
foo(2,1)
|
||||
foo(1,5)
|
||||
foo(3,2)
|
||||
foo(3,2)
|
||||
|
||||
17
tests/collections/tdeques.nim
Normal file
17
tests/collections/tdeques.nim
Normal file
@@ -0,0 +1,17 @@
|
||||
discard """
|
||||
output: '''true'''
|
||||
"""
|
||||
|
||||
import deques
|
||||
|
||||
|
||||
proc index(self: Deque[int], idx: Natural): int =
|
||||
self[idx]
|
||||
|
||||
proc main =
|
||||
var testDeque = initDeque[int]()
|
||||
testDeque.addFirst(1)
|
||||
assert testDeque.index(0) == 1
|
||||
|
||||
main()
|
||||
echo "true"
|
||||
Reference in New Issue
Block a user