From da809925773c112f5b26add9e86e9f4837342372 Mon Sep 17 00:00:00 2001 From: hlaaf Date: Fri, 21 Dec 2018 20:10:07 +0300 Subject: [PATCH] Add system.$(HSlice) and fix #7898 (#8670) * Add system.$(HSlice) and fix #7898 * Surround system.$(HSlice) with spaces --- lib/system.nim | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/system.nim b/lib/system.nim index 32a24323ea..e998ffee0a 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2656,7 +2656,7 @@ proc `$`*[T: tuple|object](x: T): string = ## of `x`. Example: ## ## .. code-block:: nim - ## $(23, 45) == "(23, 45)" + ## $(23, 45) == "(Field0: 23, Field1: 45)" ## $() == "()" result = "(" var firstElement = true @@ -2711,6 +2711,16 @@ proc `$`*[T](x: seq[T]): string = ## $(@[23, 45]) == "@[23, 45]" 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 --------------------------------------------- when not defined(nimscript) and hasAlloc: