add sink and lent annotations for xmltree and streams (#18037)

This commit is contained in:
Antonis Geralis 2021-05-18 09:16:07 +03:00 • committed by GitHub
commit 6e0fe965da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View file

@ -1252,7 +1252,7 @@ else: # after 1.3 or JS not defined
var s = StringStream(s)
s.data = ""
proc newStringStream*(s: string = ""): owned StringStream =
proc newStringStream*(s: sink string = ""): owned StringStream =
## Creates a new stream from the string `s`.
##
## See also:

View file

@ -70,7 +70,7 @@ proc newXmlNode(kind: XmlNodeKind): XmlNode =
## Creates a new ``XmlNode``.
result = XmlNode(k: kind)
proc newElement*(tag: string): XmlNode =
proc newElement*(tag: sink string): XmlNode =
## Creates a new ``XmlNode`` of kind ``xnElement`` with the given `tag`.
##
## See also:
@ -89,7 +89,7 @@ proc newElement*(tag: string): XmlNode =
result.s = @[]
# init attributes lazily to save memory
proc newText*(text: string): XmlNode =
proc newText*(text: sink string): XmlNode =
## Creates a new ``XmlNode`` of kind ``xnText`` with the text `text`.
runnableExamples:
var b = newText("my text")
@ -99,13 +99,13 @@ proc newText*(text: string): XmlNode =
result = newXmlNode(xnText)
result.fText = text
proc newVerbatimText*(text: string): XmlNode {.since: (1, 3).} =
proc newVerbatimText*(text: sink string): XmlNode {.since: (1, 3).} =
## Creates a new ``XmlNode`` of kind ``xnVerbatimText`` with the text `text`.
## **Since**: Version 1.3.
result = newXmlNode(xnVerbatimText)
result.fText = text
proc newComment*(comment: string): XmlNode =
proc newComment*(comment: sink string): XmlNode =
## Creates a new ``XmlNode`` of kind ``xnComment`` with the text `comment`.
runnableExamples:
var c = newComment("my comment")
@ -115,7 +115,7 @@ proc newComment*(comment: string): XmlNode =
result = newXmlNode(xnComment)
result.fText = comment
proc newCData*(cdata: string): XmlNode =
proc newCData*(cdata: sink string): XmlNode =
## Creates a new ``XmlNode`` of kind ``xnCData`` with the text `cdata`.
runnableExamples:
var d = newCData("my cdata")
@ -135,7 +135,7 @@ proc newEntity*(entity: string): XmlNode =
result = newXmlNode(xnEntity)
result.fText = entity
proc newXmlTree*(tag: string, children: openArray[XmlNode],
proc newXmlTree*(tag: sink string, children: openArray[XmlNode],
attributes: XmlAttributes = nil): XmlNode =
## Creates a new XML tree with `tag`, `children` and `attributes`.
##
@ -163,7 +163,7 @@ proc newXmlTree*(tag: string, children: openArray[XmlNode],
for i in 0..children.len-1: result.s[i] = children[i]
result.fAttr = attributes
proc text*(n: XmlNode): string {.inline.} =
proc text*(n: XmlNode): lent string {.inline.} =
## Gets the associated text with the node `n`.
##
## `n` can be a CDATA, Text, comment, or entity node.
@ -181,7 +181,7 @@ proc text*(n: XmlNode): string {.inline.} =
assert n.k in {xnText, xnComment, xnCData, xnEntity}
result = n.fText
proc `text=`*(n: XmlNode, text: string){.inline.} =
proc `text=`*(n: XmlNode, text: sink string) {.inline.} =
## Sets the associated text with the node `n`.
##
## `n` can be a CDATA, Text, comment, or entity node.
@ -199,7 +199,7 @@ proc `text=`*(n: XmlNode, text: string){.inline.} =
assert n.k in {xnText, xnComment, xnCData, xnEntity}
n.fText = text
proc tag*(n: XmlNode): string {.inline.} =
proc tag*(n: XmlNode): lent string {.inline.} =
## Gets the tag name of `n`.
##
## `n` has to be an ``xnElement`` node.
@ -220,7 +220,7 @@ proc tag*(n: XmlNode): string {.inline.} =
assert n.k == xnElement
result = n.fTag
proc `tag=`*(n: XmlNode, tag: string) {.inline.} =
proc `tag=`*(n: XmlNode, tag: sink string) {.inline.} =
## Sets the tag name of `n`.
##
## `n` has to be an ``xnElement`` node.