mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
Make repr(HSlice) always available (#22332)
Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
(cherry picked from commit d37b620757)
This commit is contained in:
@@ -2405,6 +2405,16 @@ when defined(nimV2):
|
||||
import system/repr_v2
|
||||
export repr_v2
|
||||
|
||||
proc repr*[T, U](x: HSlice[T, U]): string =
|
||||
## Generic `repr` operator for slices that is lifted from the components
|
||||
## of `x`. Example:
|
||||
##
|
||||
## .. code-block:: Nim
|
||||
## $(1 .. 5) == "1 .. 5"
|
||||
result = repr(x.a)
|
||||
result.add(" .. ")
|
||||
result.add(repr(x.b))
|
||||
|
||||
when hasAlloc or defined(nimscript):
|
||||
proc insert*(x: var string, item: string, i = 0.Natural) {.noSideEffect.} =
|
||||
## Inserts `item` into `x` at position `i`.
|
||||
|
||||
@@ -177,16 +177,6 @@ proc repr*[T](x: seq[T]): string =
|
||||
## $(@[23, 45]) == "@[23, 45]"
|
||||
collectionToRepr(x, "@[", ", ", "]")
|
||||
|
||||
proc repr*[T, U](x: HSlice[T, U]): string =
|
||||
## Generic `repr` operator for slices that is lifted from the components
|
||||
## of `x`. Example:
|
||||
##
|
||||
## .. code-block:: Nim
|
||||
## $(1 .. 5) == "1 .. 5"
|
||||
result = repr(x.a)
|
||||
result.add(" .. ")
|
||||
result.add(repr(x.b))
|
||||
|
||||
proc repr*[T, IDX](x: array[IDX, T]): string =
|
||||
## Generic `repr` operator for arrays that is lifted from the components.
|
||||
collectionToRepr(x, "[", ", ", "]")
|
||||
|
||||
Reference in New Issue
Block a user