Rename mget to []
- In sets, tables, strtabs, critbits, xmltree - This uses the new var parameter overloading - mget variants still exist, but are deprecated in favor of `[]` - Includes tests and fixed tests and usages of mget - The non-var `[]` now throws an exception instead of returning binary 0 or an empty string
This commit is contained in:
parent
3751019823
commit
63f9385327
12 changed files with 322 additions and 122 deletions
|
|
@ -115,11 +115,16 @@ proc `[]`* (n: XmlNode, i: int): XmlNode {.inline.} =
|
|||
assert n.k == xnElement
|
||||
result = n.s[i]
|
||||
|
||||
proc mget* (n: var XmlNode, i: int): var XmlNode {.inline.} =
|
||||
proc `[]`* (n: var XmlNode, i: int): var XmlNode {.inline.} =
|
||||
## returns the `i`'th child of `n` so that it can be modified
|
||||
assert n.k == xnElement
|
||||
result = n.s[i]
|
||||
|
||||
proc mget* (n: var XmlNode, i: int): var XmlNode {.inline, deprecated.} =
|
||||
## returns the `i`'th child of `n` so that it can be modified. Use ```[]```
|
||||
## instead.
|
||||
n[i]
|
||||
|
||||
iterator items*(n: XmlNode): XmlNode {.inline.} =
|
||||
## iterates over any child of `n`.
|
||||
assert n.k == xnElement
|
||||
|
|
@ -128,7 +133,7 @@ iterator items*(n: XmlNode): XmlNode {.inline.} =
|
|||
iterator mitems*(n: var XmlNode): var XmlNode {.inline.} =
|
||||
## iterates over any child of `n`.
|
||||
assert n.k == xnElement
|
||||
for i in 0 .. n.len-1: yield mget(n, i)
|
||||
for i in 0 .. n.len-1: yield n[i]
|
||||
|
||||
proc attrs*(n: XmlNode): XmlAttributes {.inline.} =
|
||||
## gets the attributes belonging to `n`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue