mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 18:32:11 +00:00
fix items for cstring for the JS target; makes tests green again
This commit is contained in:
@@ -2195,10 +2195,17 @@ iterator items*[T](a: set[T]): T {.inline.} =
|
||||
|
||||
iterator items*(a: cstring): char {.inline.} =
|
||||
## iterates over each item of `a`.
|
||||
var i = 0
|
||||
while a[i] != '\0':
|
||||
yield a[i]
|
||||
inc(i)
|
||||
when defined(js):
|
||||
var i = 0
|
||||
var L = len(a)
|
||||
while i < L:
|
||||
yield a[i]
|
||||
inc(i)
|
||||
else:
|
||||
var i = 0
|
||||
while a[i] != '\0':
|
||||
yield a[i]
|
||||
inc(i)
|
||||
|
||||
iterator mitems*(a: var cstring): var char {.inline.} =
|
||||
## iterates over each item of `a` so that you can modify the yielded value.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
discard """
|
||||
output: '''(x: 0, y: 0)
|
||||
(x: 5, y: 0)
|
||||
@[(x: 2, y: 4), (x: 4, y: 5), (x: 4, y: 5)]
|
||||
@[(a: 3, b: 3), (a: 1, b: 1), (a: 2, b: 2)]
|
||||
@[(x: "2", y: 4), (x: "4", y: 5), (x: "4", y: 5)]
|
||||
@[(a: "3", b: 3), (a: "1", b: 1), (a: "2", b: 2)]
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user