* Add system.$(HSlice) and fix #7898 * Surround system.$(HSlice) with spaces
This commit is contained in:
parent
0c97d3a41c
commit
da80992577
1 changed files with 11 additions and 1 deletions
|
|
@ -2656,7 +2656,7 @@ proc `$`*[T: tuple|object](x: T): string =
|
||||||
## of `x`. Example:
|
## of `x`. Example:
|
||||||
##
|
##
|
||||||
## .. code-block:: nim
|
## .. code-block:: nim
|
||||||
## $(23, 45) == "(23, 45)"
|
## $(23, 45) == "(Field0: 23, Field1: 45)"
|
||||||
## $() == "()"
|
## $() == "()"
|
||||||
result = "("
|
result = "("
|
||||||
var firstElement = true
|
var firstElement = true
|
||||||
|
|
@ -2711,6 +2711,16 @@ proc `$`*[T](x: seq[T]): string =
|
||||||
## $(@[23, 45]) == "@[23, 45]"
|
## $(@[23, 45]) == "@[23, 45]"
|
||||||
collectionToString(x, "@[", ", ", "]")
|
collectionToString(x, "@[", ", ", "]")
|
||||||
|
|
||||||
|
proc `$`*[T, U](x: HSlice[T, U]): string =
|
||||||
|
## generic ``$`` operator for slices that is lifted from the components
|
||||||
|
## of `x`. Example:
|
||||||
|
##
|
||||||
|
## .. code-block:: nim
|
||||||
|
## $(1 .. 5) == "1 .. 5"
|
||||||
|
result = $x.a
|
||||||
|
result.add(" .. ")
|
||||||
|
result.add($x.b)
|
||||||
|
|
||||||
# ----------------- GC interface ---------------------------------------------
|
# ----------------- GC interface ---------------------------------------------
|
||||||
|
|
||||||
when not defined(nimscript) and hasAlloc:
|
when not defined(nimscript) and hasAlloc:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue