diff options
author | Arne Döring <arne.doering@gmx.net> | 2018-08-17 01:24:28 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-08-17 01:24:28 +0200 |
commit | ce4383be3b10ba1ff418e5fa000a956be7816e80 (patch) | |
tree | 58b409a3841c4ea3fe71f94730d0d4df3b321322 /lib | |
parent | ac0f5c83ca0d2dba96827f07b9d7a99c107144e7 (diff) | |
download | Nim-ce4383be3b10ba1ff418e5fa000a956be7816e80.tar.gz |
fixes #8658; addQuoted on Option[T] (#8659)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/options.nim | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/pure/options.nim b/lib/pure/options.nim index b547c722a..12e38d8b5 100644 --- a/lib/pure/options.nim +++ b/lib/pure/options.nim @@ -194,9 +194,11 @@ proc `$`*[T](self: Option[T]): string = ## If the option does not have a value, the result will be `None[T]` where `T` is the name of ## the type contained in the option. if self.isSome: - "Some(" & $self.val & ")" + result = "Some(" + result.addQuoted self.val + result.add ")" else: - "None[" & name(T) & "]" + result = "None[" & name(T) & "]" when isMainModule: import unittest, sequtils @@ -247,7 +249,7 @@ when isMainModule: check(stringNone.get("Correct") == "Correct") test "$": - check($(some("Correct")) == "Some(Correct)") + check($(some("Correct")) == "Some(\"Correct\")") check($(stringNone) == "None[string]") test "map with a void result": |